* refactor: plugin build and plugin template * refactor: plugins' deps * refactor: plugins bugs * feat: add plugin static middleware * fix: bugs * refactor: frontend plugin add from remote * refactor: delete useless app/client/plugins * fix: requirejs move to local * fix: tests case * refactor: add src/client and src/server dir check * fix: lodash tree shaking * refactor: add BUILD_TIP * refactor: add file size tip * fix: bugs * fix: bug * fix: change china-division * fix: change plugins response * fix: recover dynamicImport * fix: change server src entry * fix: test error * fix: plugins sourcemap => false * fix: production file error * refactor: change build tools to vite and tsup * fix: yarn.lock * fix: bugs * fix: server build bugs * fix: delete .fatherrc.ts * fix: bug * fix: bug * fix: bugs * fix: bugs * fix: bugs * refactor: add plugin d.ts * refactor: delete fatherrc * refactor: delete father scripts * refactor: build bug * fix: bug * fix: deps adjust * fix: add build tips * fix: bug * refactor: ignore plugins when build client * docs: update doc * refactor: docs and build * fix: bug * refactor: build deps * fix: add USER_REMOTE_PLUGIN env * feat: add plugin static cache * feat: add build deps cache * fix: bugs * test: add test * fix: add plugin depden on plugin tip * fix: adjust shouldDevDependencies * fix: deps * fix: ajust deps * fix: mobile style error * fix: map error * fix: test * fix: bug * feat: lodash and dayjs import from themself * feat: @emotion/css 、ahooks and lodash to global * fix: theme-editor plugin error * fix: review * feat: move all plugins' dependencies to devDependencies * feat: change build * feat: add devPlugins * fix: bug * fix: bugs * fix: bugs * fix: bugs * feat: build bugs * fix: bugs * fix: bugs * fix: review * fix: bug * fix: change deps build * fix: bugs * fix: bug * fix: bug * fix: bugs * fix: bug * fix: bug * fix: multi language * fix: dist * fix: cronstrue * fix: getPackageClientStaticUrl * fix: antd dayjs locale * fix: plugin' d.ts import from dist * fix: multi language * fix: build types error * fix: requireModule * fix: plugin lifecycle * fix: client resource * fix: improve code * fix: locale * feat: custom build * fix: require locale * fix: improve code * fix: improve code * fix: skip preset * fix: collection undefined * feat: yarn build * fix: remove enabled * fix: update dockerfile * fix: formily version * docs: update v12 changelog * fix: devDependencies * feat: @nocobase/app * feat: generateAppDir * fix: improve code * fix: 0.11.1-alpha.5 * fix: missing @nocobase/client * fix: error * fix: add .npmignore * feat: upgrade antd version * fix: dependencies * fix: peerDependencies * fix: remove china-division dep * fix: toposort deps * fix: update dockerfile * fix: plugin template * fix: app client outputPath * feat: update docs * fix: nginx server root * fix: storage/.app-dev * fix: getChinaDivisionData * feat: plugin info * feat: update docs * fix: docs menu --------- Co-authored-by: chenos <chenlinxh@gmail.com>
4.8 KiB
v0.12: New plugin build tool
New Features
- New plugin build tool. The built plugins will be able to be used directly on the production environment without the need for a second build.
Application upgrades
Upgrade of Docker installation
No change, refer to Docker Image Upgrade Guide for upgrade.
Upgrading source code installation
The plugin build tool has been freshly upgraded, and the cache needs to be cleared after pulling new sources.
git pull # Pull the new source code.
yarn clean # Clear the cache.
For more details, see Git source upgrade guide.
Upgrading a create-nocobase-app installation
Redownload the new version via yarn create
and update the .env configuration, see [major version upgrade guide](/welcome/getting-started/upgrading/create-nocobase-app#Major version upgrade) for more details.
Incompatible changes
@nocobase/app-client and @nocobase/app-server merged into @nocobase-app
Apps installed via create-nocobase-app no longer have a packages/app directory, and custom code in packages/app needs to be moved to the custom plugin.
The dist/client path of the app has changed.
If you are configuring nginx yourself, you will need to make a similar adjustment
server {
- root /app/nocobase/packages/app/client/dist;
+ root /app/nocobase/node_modules/@nocobase/app/dist/client;
location / {
- root /app/nocobase/packages/app/client/dist;
+ root /app/nocobase/node_modules/@nocobase/app/dist/client;
try_files $uri $uri/ /index.html;
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache';
if_modified_since off;
expires off;
etag off;
}
}
Third party plugins need to be rebuilt
Refer to the third-party plugin upgrade guide below
Third-party plugin upgrade guide
The plugin directory must have both src/client
and src/server
directories.
// src/client/index.ts
import { Plugin } from '@nocobase/client';
class MyPlugin extends Plugin {
async load() {
// ...
}
}
export default MyPlugin;
// src/server/index.ts
import { Plugin } from '@nocobase/server';
class MyPlugin extends Plugin {
async load() {
// ...
}
}
export default MyPlugin;
Specific demo code can be referred to: sample-hello
Plugin's multilingual placement src/locale
directory
Both frontend and backend, multi-language translation files are placed in the src/locale
directory, so the plugin doesn't need to load multi-language packages by itself.
Adjustment of plugin dependencies
The dependencies of the plugin are divided into its own dependencies and global dependencies. Global dependencies are directly used globally and will not be packaged into the plugin product, while its own dependencies will be packaged into the product. After the plug-in is built, the production environment is plug-and-play, and there is no need to install dependencies or build twice. Adjustments to plugin dependencies include:
- Put
@nocobase/*
related packages intopeerDependencies
and specify the version number as0.x
; - Place other dependencies in
devDependencies
, notdependencies
, as the plugin will extract all the dependencies required by the production environment after packaging.
{
"devDependencies": {
"@formily/react": "2.x",
"@formily/shared": "2.x",
"ahooks": "3.x",
"antd": "5.x",
"dayjs": "1.x",
"i18next": "22.x",
"react": "18.x",
"react-dom": "18.x",
"react-i18next": "11.x"
},
"peerDependencies": {
"@nocobase/actions": "0.x",
"@nocobase/client": "0.x",
"@nocobase/database": "0.x",
"@nocobase/resourcer": "0.x",
"@nocobase/server": "0.x",
"@nocobase/test": "0.x",
"@nocobase/utils": "0.x"
}
}
The output path of the plugin has been changed from lib
to dist
dist directory structure
|- dist
|- client # Client-side, umd
|- index.js
|- index.d.ts
|- server # Server-side, cjs
|- index.js
|- index.d.ts
|- others
|- locale # multilingual package
|- node_modules # server dependencies
Other related adjustments include:
Adjustment of the main parameter of package.json
{
- "main": "./lib/server/index.js",
+ "main": "./dist/server/index.js",
}
client.d.ts
export * from './dist/client';
export { default } from './dist/client';
client.js
module.exports = require('./dist/client/index.js');
server.d.ts
export * from './dist/server';
export { default } from './dist/server';
server.js
module.exports = require('./dist/server/index.js');