mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 17:46:36 +00:00
5df3b0e75d
* 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.3 KiB
4.3 KiB
v0.12:全新的插件构建工具
新特性
- 全新的插件构建工具。构建好的插件将可以直接在生产环境上使用,无需二次构建。
应用升级
Docker 安装的升级
无变化,升级参考 Docker 镜像升级指南
源码安装的升级
插件构建工具已全新升级,在拉取新源码之后,需要清除缓存。
git pull # 拉取新源码
yarn clean # 清除缓存
更多详情参考 Git 源码升级指南
create-nocobase-app 安装的升级
通过 yarn create
重新下载新版本,再更新 .env 配置,更多详情参考 大版本升级指南
不兼容的变化
@nocobase/app-client 和 @nocobase/app-server 合并为 @nocobase-app
通过 create-nocobase-app 安装的应用不再有 packages/app 目录了,在 packages/app 里自定义的代码,需要移至自定义插件中。
app 的 dist/client 路径变更
如果是自己配置的 nginx,需要做类似调整
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;
}
}
第三方插件需要重新构建
参考下文的第三方插件升级指南
第三方插件升级指南
插件目录必须同时有 src/client
和 src/server
目录
// 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;
具体 Demo 代码可以参考:sample-hello
插件的多语言放置 src/locale
目录
无论前后端,多语言翻译文件都统一放在 src/locale
目录,插件无需自己加载多语言包。
插件依赖的调整
插件的依赖分为自身的依赖和全局依赖,全局依赖直接使用全局,不会打包到插件产物中,自身的依赖会被打包到产物中。插件构建之后,生产环境即插即用,无需再安装依赖或二次构建。插件依赖的调整包括:
- 将
@nocobase/*
相关包放到peerDependencies
里,并指定版本号为0.x
; - 其他依赖放到
devDependencies
里,不要放dependencies
里,因为插件打包之后会将生产环境所需依赖全部提取了。
{
"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"
}
}
插件的构建产物从 lib
目录变更为 dist
目录
dist 目录介绍
|- dist
|- client # 前端,umd 规范
|- index.js
|- index.d.ts
|- server # 后端,cjs 规范
|- index.js
|- index.d.ts
|- 其他文件
|- locale # 多语言目录
|- node_modules # 后端依赖
其他相关调整包括:
package.json 的 main 参数调整
{
- "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');