rc-pluggable-widgets-tools v8.18.3
Pluggable Widgets Tools
About
A toolset to build, test, format, run, release and lint your Pluggable Widgets
How to install
Install via NPM using npm install rc-pluggable-widgets-tools (use node.js version >= 12). When installing via NPM v7.x.x, use npm install rc-pluggable-widgets-tools --legacy-peer-deps.
Even better is creating your widget using Pluggable Widgets Generator which scaffolds the correct project setup.
How to use
In your package.json scripts, use the following command with the desired task: pluggable-widgets-tools task
Available tasks
start:webBuild and watch the changes of your Web widgetstart:serverBuild and watch the changes of your Web widget. Start a web server, that reloads the widget code without the need to re-run the Mendix project. Accepts option--opento automatically open your browser.start:nativeBuild and watch the changes of your Native widgetbuild:webBuild your Web widgetbuild:nativeBuild your Native widgetrelease:webCreate a release build of your Web widgetrelease:nativeCreate a release build of your Native widgetlintLint your project using ESLint and Prettierlint:fixFix lint problems/warning of ESLint and PrettierformatFormat your code using Prettiertest:unit:webRun unit tests for your Web widget. Accepts option--uto update snapshots,--no-cacheto remove existing caches,--ciassumes use of a CI environment,--coverageto support coverage test.test:unit:nativeRun unit tests for your Native widget. Accepts option--uto update snapshots,--no-cacheto remove existing caches,--ciassumes use of a CI environment,--coverageto support coverage test.test:e2eExecute end-to-end tests in your Web widget
Example
"name": "MyWidget",
"widgetName": "com.company.widgets.MyWidget",
"version": "1.0.0",
"config": {
"projectPath": "../MxTestProject/",
"mendixHost": "http://localhost:8080",
"developmentPort": "3000"
},
"scripts": {
"build": "pluggable-widgets-tools build:web",
"lint": "pluggable-widgets-tools lint",
"lint:fix": "pluggable-widgets-tools lint:fix",
"test:unit": "pluggable-widgets-tools test:unit --coverage"
}Project layout
src/MyWidget.xml- widget definitionMyWidget.[tj]sx- widget client componetMyWidget.editorPreview.[tj]sx- (optional) widget previewMyWidget.editorConfig.[tj]s- (optional) widget editor configurationcomopnents/MyComponent.[tj]s- code of widget's components__tests__/MyComponent.spec.[tj]s- tests for widget's components
.eslint.js- configuration for ESLint. We recoommend to just re-exportrc-pluggable-widgets-tools/configs/eslint.ts.base.jsonprettier.config.js- configuration for Prettier. We recommend to just re-exportrc-pluggable-widgets-tools/configs/prettier.base.jsontsconfig.json- configuration for TypeScript. We recommend to just extendrc-pluggable-widgets-tools/configs/tsconfig.base.jsonwebpack.config.dev.js- (optional) custom configurations for webpack bundler (both for client and preview components) when running in development mode. The standard confiugration can be imported fromrc-pluggable-widgets-tools/configs/webpack.config.dev.jsfor web and fromrc-pluggable-widgets-tools/configs/webpack.native.config.jsfor native apps.webpack.config.prod.js- (optional) custom configuration for webpack bundler in release mode.package.json- widget package definitions, inluding its dependencies, scripts, and basic configuration (widgetNameandconfig.projectPathin particular)
Migrating from 8.9 to 8.10
React-hot-loader is not anymore needed to provide auto refresh functionality. That is, you can remove its usage from the code: your main entry point can simply be export default MyWidget; instead of export default hot(MyWidget);.
If you do not change your widget, hot will be replaced with a noop function that has no effect.