Skip to content

Commit

Permalink
feat(docs): hello-build 只提供 esm 的包
Browse files Browse the repository at this point in the history
  • Loading branch information
dogodo-cc committed Apr 1, 2024
1 parent e5dc25b commit 6cecc72
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 167 deletions.
130 changes: 6 additions & 124 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
"docs:dev": "npm run dev -w @cocos-fe/document",
"docs:build": "npm run build -w @cocos-fe/document",
"docs:serve": "npm run serve -w @cocos-fe/document",
"hello-build:dev": "npm run dev -w @cocos-fe/hello-build",
"hello-build:build": "npm run build -w @cocos-fe/hello-build",
"editor-tool:dev": "npm run dev -w cocos-editor-tool",
"editor-tool:build": "npm run build -w cocos-editor-tool",
"lint:js": "cross-env NODE_ENV=production eslint --fix --ext .js,.vue,.ts",
Expand Down
14 changes: 14 additions & 0 deletions packages/hello-build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ hi-cocos build .

命令中 `.` 代表了当前插件。

## 问题

如果报错 bin 文件没有执行权限,可以

```sh
chmod 777 path/to/node_modules/.bin/hi-cocos
```

## TODO

当前为了兼容编辑器工作流的 CJS 导入方式,做了一些牺牲。如果后期工作流支持 ESM 之后,需要做如下工作:
Expand All @@ -138,3 +146,9 @@ rollup-plugin-node-externals@5 在配合 vite 的 config 时不生效。[v7](htt
a few minutes later

那么是否意味着,如果我只提供 esm 的包,我已经可以抛弃 rollup 了。目前用 rollup 打包 hello-build 只是为了 esm 和 cjs 两种格式的输出。

就这么干!!

版本以 1.0.0 开始的只提供 esm 版本,且该包的构建剥离 rollup ,直接源码发布。

为了防止后续必须提供 cjs 的版本,我们将继续 从 0.0.19 开始提供。 在 hello_build_cjs 这个分支进行发布。
19 changes: 5 additions & 14 deletions packages/hello-build/package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
{
"name": "@cocos-fe/hello-build",
"version": "0.0.18",
"version": "1.0.0",
"description": "cocos editor 插件构建工具",
"type": "module",
"main": "bin/core.cjs",
"module": "bin/core.mjs",
"scripts": {
"dev": "npx rollup -c --watch",
"build": "npx rollup -c",
"postbuild": "sh postbuild.sh"
},
"module": "src/core.js",
"exports": {
".": {
"require": "./bin/core.cjs",
"import": "./bin/core.mjs"
"import": "./src/core.js"
}
},
"bin": {
"hi-cocos": "bin/index.mjs"
"hi-cocos": "src/index.js"
},
"dependencies": {
"@vitejs/plugin-vue": "^5.0.4",
Expand All @@ -36,12 +29,10 @@
"node": ">=18"
},
"devDependencies": {
"rollup": "^4.13.2",
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-node-externals": "^7.1.1"
},
"files": [
"bin",
"src",
"README.md"
]
}
2 changes: 0 additions & 2 deletions packages/hello-build/postbuild.sh

This file was deleted.

25 changes: 0 additions & 25 deletions packages/hello-build/rollup.config.js

This file was deleted.

0 comments on commit 6cecc72

Please sign in to comment.