From 060924e241e6aa31c3424334ffdc3d5a0aa42353 Mon Sep 17 00:00:00 2001 From: winixt Date: Thu, 12 May 2022 10:50:53 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=9B=B4=E6=94=B9=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E5=99=A8=E5=90=8D=E7=A7=B0=20build=20>=20builder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.config.js | 4 +- .../templates/app/h5/package.json | 2 +- .../templates/app/pc/package.json | 2 +- .../fes-build-webpack/src/utils/constants.js | 6 -- .../src/utils/generateExports.js | 60 ------------------- .../LICENSE | 0 .../README.md | 0 .../package.json | 6 +- .../src/commands/build/babelPolyfillPlugin.js | 0 .../src/commands/build/getBuildConfig.js | 0 .../src/commands/build/index.js | 0 .../src/commands/dev/getDevConfig.js | 0 .../src/commands/dev/index.js | 0 .../src/commands/dev/viteMiddlewarePlugin.js | 0 .../src/common/SFCConfigBlockPlugin.js | 0 .../src/common/getConfig.js | 0 .../src/common/getDefine.js | 0 .../src/features/viteAnalyze.js | 0 .../src/features/viteHtml.js | 0 .../src/features/viteLegacy.js | 0 .../src/features/viteOption.js | 0 .../src/features/viteVueJsx.js | 0 .../src/features/viteVuePlugin.js | 0 .../src/index.js | 0 .../src/registerBuilder.js | 0 .../src/registerMethods.js | 0 .../src/registerType.js | 0 .../types.d.ts | 0 .../LICENSE | 0 .../README.md | 0 .../package.json | 6 +- .../src/index.js | 0 .../src/plugins/commands/build/build.js | 0 .../src/plugins/commands/build/index.js | 2 +- .../src/plugins/commands/buildDevUtils.js | 0 .../commands/dev/connectHistoryMiddleware.js | 0 .../src/plugins/commands/dev/devServer.js | 0 .../src/plugins/commands/dev/index.js | 2 +- .../src/plugins/commands/webpack/index.js | 0 .../src/plugins/commands/webpackConfig/css.js | 0 .../plugins/commands/webpackConfig/define.js | 0 .../commands/webpackConfig/getBabelOpts.js | 0 .../plugins/commands/webpackConfig/html.js | 0 .../commands/webpackConfig/index-default.html | 0 .../plugins/commands/webpackConfig/index.js | 0 .../commands/webpackConfig/minimizer.js | 0 .../plugins/commands/webpackConfig/pitcher.js | 0 .../src/plugins/commands/webpackConfig/vue.js | 0 .../src/plugins/features/analyze.js | 0 .../src/plugins/features/chainWebpack.js | 0 .../src/plugins/features/copy.js | 0 .../src/plugins/features/cssLoader.js | 0 .../src/plugins/features/devServer.js | 0 .../src/plugins/features/devtool.js | 0 .../src/plugins/features/exportStatic.js | 0 .../src/plugins/features/externals.js | 0 .../src/plugins/features/extraBabelPlugins.js | 0 .../src/plugins/features/extraBabelPresets.js | 0 .../plugins/features/extraPostCSSPlugins.js | 0 .../src/plugins/features/html.js | 0 .../src/plugins/features/lessLoader.js | 0 .../plugins/features/nodeModulesTransform.js | 0 .../src/plugins/features/postcssLoader.js | 0 .../src/plugins/features/vueLoader.js | 0 .../src/plugins/registerBuilder.js | 0 .../src/plugins/registerMethods.js | 0 .../src/plugins/registerType.js | 0 .../src/utils/constants.js | 4 ++ .../src/utils/generateExports.js | 30 ++++++++++ .../types.d.ts | 0 .../src/service/utils/pluginUtils.js | 6 +- .../examples/micro/package.json | 2 +- .../examples/vite-main/.fes.js | 2 +- .../examples/webpack-main/.fes.js | 2 +- packages/fes-template-h5/package.json | 2 +- packages/fes-template-vite/package.json | 2 +- packages/fes-template/.fes.js | 2 +- 77 files changed, 55 insertions(+), 87 deletions(-) delete mode 100644 packages/fes-build-webpack/src/utils/constants.js delete mode 100644 packages/fes-build-webpack/src/utils/generateExports.js rename packages/{fes-build-vite => fes-builder-vite}/LICENSE (100%) rename packages/{fes-build-vite => fes-builder-vite}/README.md (100%) rename packages/{fes-build-vite => fes-builder-vite}/package.json (89%) rename packages/{fes-build-vite => fes-builder-vite}/src/commands/build/babelPolyfillPlugin.js (100%) rename packages/{fes-build-vite => fes-builder-vite}/src/commands/build/getBuildConfig.js (100%) rename packages/{fes-build-vite => fes-builder-vite}/src/commands/build/index.js (100%) rename packages/{fes-build-vite => fes-builder-vite}/src/commands/dev/getDevConfig.js (100%) rename packages/{fes-build-vite => fes-builder-vite}/src/commands/dev/index.js (100%) rename packages/{fes-build-vite => fes-builder-vite}/src/commands/dev/viteMiddlewarePlugin.js (100%) rename packages/{fes-build-vite => fes-builder-vite}/src/common/SFCConfigBlockPlugin.js (100%) rename packages/{fes-build-vite => fes-builder-vite}/src/common/getConfig.js (100%) rename packages/{fes-build-vite => fes-builder-vite}/src/common/getDefine.js (100%) rename packages/{fes-build-vite => fes-builder-vite}/src/features/viteAnalyze.js (100%) rename packages/{fes-build-vite => fes-builder-vite}/src/features/viteHtml.js (100%) rename packages/{fes-build-vite => fes-builder-vite}/src/features/viteLegacy.js (100%) rename packages/{fes-build-vite => fes-builder-vite}/src/features/viteOption.js (100%) rename packages/{fes-build-vite => fes-builder-vite}/src/features/viteVueJsx.js (100%) rename packages/{fes-build-vite => fes-builder-vite}/src/features/viteVuePlugin.js (100%) rename packages/{fes-build-vite => fes-builder-vite}/src/index.js (100%) rename packages/{fes-build-vite => fes-builder-vite}/src/registerBuilder.js (100%) rename packages/{fes-build-vite => fes-builder-vite}/src/registerMethods.js (100%) rename packages/{fes-build-vite => fes-builder-vite}/src/registerType.js (100%) rename packages/{fes-build-vite => fes-builder-vite}/types.d.ts (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/LICENSE (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/README.md (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/package.json (93%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/index.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/commands/build/build.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/commands/build/index.js (97%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/commands/buildDevUtils.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/commands/dev/connectHistoryMiddleware.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/commands/dev/devServer.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/commands/dev/index.js (98%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/commands/webpack/index.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/commands/webpackConfig/css.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/commands/webpackConfig/define.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/commands/webpackConfig/getBabelOpts.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/commands/webpackConfig/html.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/commands/webpackConfig/index-default.html (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/commands/webpackConfig/index.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/commands/webpackConfig/minimizer.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/commands/webpackConfig/pitcher.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/commands/webpackConfig/vue.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/features/analyze.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/features/chainWebpack.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/features/copy.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/features/cssLoader.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/features/devServer.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/features/devtool.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/features/exportStatic.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/features/externals.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/features/extraBabelPlugins.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/features/extraBabelPresets.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/features/extraPostCSSPlugins.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/features/html.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/features/lessLoader.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/features/nodeModulesTransform.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/features/postcssLoader.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/features/vueLoader.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/registerBuilder.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/registerMethods.js (100%) rename packages/{fes-build-webpack => fes-builder-webpack}/src/plugins/registerType.js (100%) create mode 100644 packages/fes-builder-webpack/src/utils/constants.js create mode 100644 packages/fes-builder-webpack/src/utils/generateExports.js rename packages/{fes-build-webpack => fes-builder-webpack}/types.d.ts (100%) diff --git a/build.config.js b/build.config.js index 060ea34b..305b6191 100644 --- a/build.config.js +++ b/build.config.js @@ -4,8 +4,8 @@ module.exports = { 'fes', 'fes-compiler', 'fes-preset-built-in', - 'fes-build-vite', - 'fes-build-webpack', + 'fes-builder-vite', + 'fes-builder-webpack', 'fes-runtime', 'fes-utils', 'fes-plugin-access', diff --git a/packages/create-fes-app/templates/app/h5/package.json b/packages/create-fes-app/templates/app/h5/package.json index 632e9c38..8f2d4033 100644 --- a/packages/create-fes-app/templates/app/h5/package.json +++ b/packages/create-fes-app/templates/app/h5/package.json @@ -48,7 +48,7 @@ "@fesjs/fes": "^2.0.0", "@fesjs/plugin-icon": "^2.0.0", "@fesjs/plugin-request": "^2.0.0", - "@fesjs/build-webpack": "^1.0.0", + "@fesjs/builder-webpack": "^1.0.0", "vue": "^3.2.6", "core-js": "^3.8.3" }, diff --git a/packages/create-fes-app/templates/app/pc/package.json b/packages/create-fes-app/templates/app/pc/package.json index d7d99e21..cb332b8b 100644 --- a/packages/create-fes-app/templates/app/pc/package.json +++ b/packages/create-fes-app/templates/app/pc/package.json @@ -53,7 +53,7 @@ "@fesjs/plugin-model": "^2.0.0", "@fesjs/plugin-enums": "^2.0.0", "@fesjs/fes-design": "^0.4.0", - "@fesjs/build-webpack": "^1.0.0", + "@fesjs/builder-webpack": "^1.0.0", "vue": "^3.2.6", "core-js": "^3.8.3" }, diff --git a/packages/fes-build-webpack/src/utils/constants.js b/packages/fes-build-webpack/src/utils/constants.js deleted file mode 100644 index f9766e28..00000000 --- a/packages/fes-build-webpack/src/utils/constants.js +++ /dev/null @@ -1,6 +0,0 @@ -import { winPath } from '@fesjs/utils'; -import { dirname } from 'path'; - -export const runtimePath = winPath( - dirname(require.resolve('@fesjs/runtime/package.json')) -); diff --git a/packages/fes-build-webpack/src/utils/generateExports.js b/packages/fes-build-webpack/src/utils/generateExports.js deleted file mode 100644 index 23fa254f..00000000 --- a/packages/fes-build-webpack/src/utils/generateExports.js +++ /dev/null @@ -1,60 +0,0 @@ -import { lodash, winPath } from '@fesjs/utils'; -import assert from 'assert'; -import path from 'path'; - -const reserveLibrarys = ['fes']; // reserve library -// todo 插件导出内容冲突问题待解决 -const reserveExportsNames = [ - 'Link', - 'NavLink', - 'Redirect', - 'dynamic', - 'withRouter', - 'Route' -]; - -export default function generateExports(basePath, { item, fesExportsHook }) { - assert(item.source, 'source should be supplied.'); - const source = path.relative(path.basename(basePath), item.source); - assert( - item.exportAll || item.specifiers, - 'exportAll or specifiers should be supplied.' - ); - assert( - !reserveLibrarys.includes(source), - `${source} is reserve library, Please don't use it.` - ); - if (item.exportAll) { - return `export * from '${winPath(source)}';`; - } - assert( - Array.isArray(item.specifiers), - `specifiers should be Array, but got ${item.specifiers.toString()}.` - ); - const specifiersStrArr = item.specifiers.map((specifier) => { - if (typeof specifier === 'string') { - assert( - !reserveExportsNames.includes(specifier), - `${specifier} is reserve name, you can use 'exported' to set alias.` - ); - assert( - !fesExportsHook[specifier], - `${specifier} is Defined, you can use 'exported' to set alias.` - ); - fesExportsHook[specifier] = true; - return specifier; - } - assert( - lodash.isPlainObject(specifier), - `Configure item context should be Plain Object, but got ${specifier}.` - ); - assert( - specifier.local && specifier.exported, - 'local and exported should be supplied.' - ); - return `${specifier.local} as ${specifier.exported}`; - }); - return `export { ${specifiersStrArr.join(', ')} } from '${winPath( - source - )}';`; -} diff --git a/packages/fes-build-vite/LICENSE b/packages/fes-builder-vite/LICENSE similarity index 100% rename from packages/fes-build-vite/LICENSE rename to packages/fes-builder-vite/LICENSE diff --git a/packages/fes-build-vite/README.md b/packages/fes-builder-vite/README.md similarity index 100% rename from packages/fes-build-vite/README.md rename to packages/fes-builder-vite/README.md diff --git a/packages/fes-build-vite/package.json b/packages/fes-builder-vite/package.json similarity index 89% rename from packages/fes-build-vite/package.json rename to packages/fes-builder-vite/package.json index 72fe1f25..5b62a999 100644 --- a/packages/fes-build-vite/package.json +++ b/packages/fes-builder-vite/package.json @@ -1,7 +1,7 @@ { - "name": "@fesjs/build-vite", + "name": "@fesjs/builder-vite", "version": "1.0.0", - "description": "@fesjs/build-vite", + "description": "@fesjs/builder-vite", "main": "lib/index.js", "files": [ "lib" @@ -9,7 +9,7 @@ "repository": { "type": "git", "url": "git+https://github.com/WeBankFinTech/fes.js.git", - "directory": "packages/fes-build-vite" + "directory": "packages/fes-builder-vite" }, "keywords": [ "fes" diff --git a/packages/fes-build-vite/src/commands/build/babelPolyfillPlugin.js b/packages/fes-builder-vite/src/commands/build/babelPolyfillPlugin.js similarity index 100% rename from packages/fes-build-vite/src/commands/build/babelPolyfillPlugin.js rename to packages/fes-builder-vite/src/commands/build/babelPolyfillPlugin.js diff --git a/packages/fes-build-vite/src/commands/build/getBuildConfig.js b/packages/fes-builder-vite/src/commands/build/getBuildConfig.js similarity index 100% rename from packages/fes-build-vite/src/commands/build/getBuildConfig.js rename to packages/fes-builder-vite/src/commands/build/getBuildConfig.js diff --git a/packages/fes-build-vite/src/commands/build/index.js b/packages/fes-builder-vite/src/commands/build/index.js similarity index 100% rename from packages/fes-build-vite/src/commands/build/index.js rename to packages/fes-builder-vite/src/commands/build/index.js diff --git a/packages/fes-build-vite/src/commands/dev/getDevConfig.js b/packages/fes-builder-vite/src/commands/dev/getDevConfig.js similarity index 100% rename from packages/fes-build-vite/src/commands/dev/getDevConfig.js rename to packages/fes-builder-vite/src/commands/dev/getDevConfig.js diff --git a/packages/fes-build-vite/src/commands/dev/index.js b/packages/fes-builder-vite/src/commands/dev/index.js similarity index 100% rename from packages/fes-build-vite/src/commands/dev/index.js rename to packages/fes-builder-vite/src/commands/dev/index.js diff --git a/packages/fes-build-vite/src/commands/dev/viteMiddlewarePlugin.js b/packages/fes-builder-vite/src/commands/dev/viteMiddlewarePlugin.js similarity index 100% rename from packages/fes-build-vite/src/commands/dev/viteMiddlewarePlugin.js rename to packages/fes-builder-vite/src/commands/dev/viteMiddlewarePlugin.js diff --git a/packages/fes-build-vite/src/common/SFCConfigBlockPlugin.js b/packages/fes-builder-vite/src/common/SFCConfigBlockPlugin.js similarity index 100% rename from packages/fes-build-vite/src/common/SFCConfigBlockPlugin.js rename to packages/fes-builder-vite/src/common/SFCConfigBlockPlugin.js diff --git a/packages/fes-build-vite/src/common/getConfig.js b/packages/fes-builder-vite/src/common/getConfig.js similarity index 100% rename from packages/fes-build-vite/src/common/getConfig.js rename to packages/fes-builder-vite/src/common/getConfig.js diff --git a/packages/fes-build-vite/src/common/getDefine.js b/packages/fes-builder-vite/src/common/getDefine.js similarity index 100% rename from packages/fes-build-vite/src/common/getDefine.js rename to packages/fes-builder-vite/src/common/getDefine.js diff --git a/packages/fes-build-vite/src/features/viteAnalyze.js b/packages/fes-builder-vite/src/features/viteAnalyze.js similarity index 100% rename from packages/fes-build-vite/src/features/viteAnalyze.js rename to packages/fes-builder-vite/src/features/viteAnalyze.js diff --git a/packages/fes-build-vite/src/features/viteHtml.js b/packages/fes-builder-vite/src/features/viteHtml.js similarity index 100% rename from packages/fes-build-vite/src/features/viteHtml.js rename to packages/fes-builder-vite/src/features/viteHtml.js diff --git a/packages/fes-build-vite/src/features/viteLegacy.js b/packages/fes-builder-vite/src/features/viteLegacy.js similarity index 100% rename from packages/fes-build-vite/src/features/viteLegacy.js rename to packages/fes-builder-vite/src/features/viteLegacy.js diff --git a/packages/fes-build-vite/src/features/viteOption.js b/packages/fes-builder-vite/src/features/viteOption.js similarity index 100% rename from packages/fes-build-vite/src/features/viteOption.js rename to packages/fes-builder-vite/src/features/viteOption.js diff --git a/packages/fes-build-vite/src/features/viteVueJsx.js b/packages/fes-builder-vite/src/features/viteVueJsx.js similarity index 100% rename from packages/fes-build-vite/src/features/viteVueJsx.js rename to packages/fes-builder-vite/src/features/viteVueJsx.js diff --git a/packages/fes-build-vite/src/features/viteVuePlugin.js b/packages/fes-builder-vite/src/features/viteVuePlugin.js similarity index 100% rename from packages/fes-build-vite/src/features/viteVuePlugin.js rename to packages/fes-builder-vite/src/features/viteVuePlugin.js diff --git a/packages/fes-build-vite/src/index.js b/packages/fes-builder-vite/src/index.js similarity index 100% rename from packages/fes-build-vite/src/index.js rename to packages/fes-builder-vite/src/index.js diff --git a/packages/fes-build-vite/src/registerBuilder.js b/packages/fes-builder-vite/src/registerBuilder.js similarity index 100% rename from packages/fes-build-vite/src/registerBuilder.js rename to packages/fes-builder-vite/src/registerBuilder.js diff --git a/packages/fes-build-vite/src/registerMethods.js b/packages/fes-builder-vite/src/registerMethods.js similarity index 100% rename from packages/fes-build-vite/src/registerMethods.js rename to packages/fes-builder-vite/src/registerMethods.js diff --git a/packages/fes-build-vite/src/registerType.js b/packages/fes-builder-vite/src/registerType.js similarity index 100% rename from packages/fes-build-vite/src/registerType.js rename to packages/fes-builder-vite/src/registerType.js diff --git a/packages/fes-build-vite/types.d.ts b/packages/fes-builder-vite/types.d.ts similarity index 100% rename from packages/fes-build-vite/types.d.ts rename to packages/fes-builder-vite/types.d.ts diff --git a/packages/fes-build-webpack/LICENSE b/packages/fes-builder-webpack/LICENSE similarity index 100% rename from packages/fes-build-webpack/LICENSE rename to packages/fes-builder-webpack/LICENSE diff --git a/packages/fes-build-webpack/README.md b/packages/fes-builder-webpack/README.md similarity index 100% rename from packages/fes-build-webpack/README.md rename to packages/fes-builder-webpack/README.md diff --git a/packages/fes-build-webpack/package.json b/packages/fes-builder-webpack/package.json similarity index 93% rename from packages/fes-build-webpack/package.json rename to packages/fes-builder-webpack/package.json index 8ad778f1..8084c747 100644 --- a/packages/fes-build-webpack/package.json +++ b/packages/fes-builder-webpack/package.json @@ -1,7 +1,7 @@ { - "name": "@fesjs/build-webpack", + "name": "@fesjs/builder-webpack", "version": "1.0.0", - "description": "@fesjs/build-webpack", + "description": "@fesjs/builder-webpack", "main": "lib/index.js", "types": "lib/index.d.ts", "files": [ @@ -10,7 +10,7 @@ "repository": { "type": "git", "url": "git+https://github.com/WeBankFinTech/fes.js.git", - "directory": "packages/fes-build-webpack" + "directory": "packages/fes-builder-webpack" }, "keywords": [ "fes" diff --git a/packages/fes-build-webpack/src/index.js b/packages/fes-builder-webpack/src/index.js similarity index 100% rename from packages/fes-build-webpack/src/index.js rename to packages/fes-builder-webpack/src/index.js diff --git a/packages/fes-build-webpack/src/plugins/commands/build/build.js b/packages/fes-builder-webpack/src/plugins/commands/build/build.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/commands/build/build.js rename to packages/fes-builder-webpack/src/plugins/commands/build/build.js diff --git a/packages/fes-build-webpack/src/plugins/commands/build/index.js b/packages/fes-builder-webpack/src/plugins/commands/build/index.js similarity index 97% rename from packages/fes-build-webpack/src/plugins/commands/build/index.js rename to packages/fes-builder-webpack/src/plugins/commands/build/index.js index 4475c0ce..f06c7c86 100644 --- a/packages/fes-build-webpack/src/plugins/commands/build/index.js +++ b/packages/fes-builder-webpack/src/plugins/commands/build/index.js @@ -7,7 +7,7 @@ import { relative } from 'path'; import { existsSync } from 'fs'; import { Logger } from '@fesjs/compiler'; -const logger = new Logger('fes:build-webpack'); +const logger = new Logger('fes:builder-webpack'); export default function (api) { const { diff --git a/packages/fes-build-webpack/src/plugins/commands/buildDevUtils.js b/packages/fes-builder-webpack/src/plugins/commands/buildDevUtils.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/commands/buildDevUtils.js rename to packages/fes-builder-webpack/src/plugins/commands/buildDevUtils.js diff --git a/packages/fes-build-webpack/src/plugins/commands/dev/connectHistoryMiddleware.js b/packages/fes-builder-webpack/src/plugins/commands/dev/connectHistoryMiddleware.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/commands/dev/connectHistoryMiddleware.js rename to packages/fes-builder-webpack/src/plugins/commands/dev/connectHistoryMiddleware.js diff --git a/packages/fes-build-webpack/src/plugins/commands/dev/devServer.js b/packages/fes-builder-webpack/src/plugins/commands/dev/devServer.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/commands/dev/devServer.js rename to packages/fes-builder-webpack/src/plugins/commands/dev/devServer.js diff --git a/packages/fes-build-webpack/src/plugins/commands/dev/index.js b/packages/fes-builder-webpack/src/plugins/commands/dev/index.js similarity index 98% rename from packages/fes-build-webpack/src/plugins/commands/dev/index.js rename to packages/fes-builder-webpack/src/plugins/commands/dev/index.js index 5e4fd7e8..d66be75e 100644 --- a/packages/fes-build-webpack/src/plugins/commands/dev/index.js +++ b/packages/fes-builder-webpack/src/plugins/commands/dev/index.js @@ -1,6 +1,6 @@ import { Logger } from '@fesjs/compiler'; -const logger = new Logger('fes:build-webpack'); +const logger = new Logger('fes:builder-webpack'); export default (api) => { const { diff --git a/packages/fes-build-webpack/src/plugins/commands/webpack/index.js b/packages/fes-builder-webpack/src/plugins/commands/webpack/index.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/commands/webpack/index.js rename to packages/fes-builder-webpack/src/plugins/commands/webpack/index.js diff --git a/packages/fes-build-webpack/src/plugins/commands/webpackConfig/css.js b/packages/fes-builder-webpack/src/plugins/commands/webpackConfig/css.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/commands/webpackConfig/css.js rename to packages/fes-builder-webpack/src/plugins/commands/webpackConfig/css.js diff --git a/packages/fes-build-webpack/src/plugins/commands/webpackConfig/define.js b/packages/fes-builder-webpack/src/plugins/commands/webpackConfig/define.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/commands/webpackConfig/define.js rename to packages/fes-builder-webpack/src/plugins/commands/webpackConfig/define.js diff --git a/packages/fes-build-webpack/src/plugins/commands/webpackConfig/getBabelOpts.js b/packages/fes-builder-webpack/src/plugins/commands/webpackConfig/getBabelOpts.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/commands/webpackConfig/getBabelOpts.js rename to packages/fes-builder-webpack/src/plugins/commands/webpackConfig/getBabelOpts.js diff --git a/packages/fes-build-webpack/src/plugins/commands/webpackConfig/html.js b/packages/fes-builder-webpack/src/plugins/commands/webpackConfig/html.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/commands/webpackConfig/html.js rename to packages/fes-builder-webpack/src/plugins/commands/webpackConfig/html.js diff --git a/packages/fes-build-webpack/src/plugins/commands/webpackConfig/index-default.html b/packages/fes-builder-webpack/src/plugins/commands/webpackConfig/index-default.html similarity index 100% rename from packages/fes-build-webpack/src/plugins/commands/webpackConfig/index-default.html rename to packages/fes-builder-webpack/src/plugins/commands/webpackConfig/index-default.html diff --git a/packages/fes-build-webpack/src/plugins/commands/webpackConfig/index.js b/packages/fes-builder-webpack/src/plugins/commands/webpackConfig/index.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/commands/webpackConfig/index.js rename to packages/fes-builder-webpack/src/plugins/commands/webpackConfig/index.js diff --git a/packages/fes-build-webpack/src/plugins/commands/webpackConfig/minimizer.js b/packages/fes-builder-webpack/src/plugins/commands/webpackConfig/minimizer.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/commands/webpackConfig/minimizer.js rename to packages/fes-builder-webpack/src/plugins/commands/webpackConfig/minimizer.js diff --git a/packages/fes-build-webpack/src/plugins/commands/webpackConfig/pitcher.js b/packages/fes-builder-webpack/src/plugins/commands/webpackConfig/pitcher.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/commands/webpackConfig/pitcher.js rename to packages/fes-builder-webpack/src/plugins/commands/webpackConfig/pitcher.js diff --git a/packages/fes-build-webpack/src/plugins/commands/webpackConfig/vue.js b/packages/fes-builder-webpack/src/plugins/commands/webpackConfig/vue.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/commands/webpackConfig/vue.js rename to packages/fes-builder-webpack/src/plugins/commands/webpackConfig/vue.js diff --git a/packages/fes-build-webpack/src/plugins/features/analyze.js b/packages/fes-builder-webpack/src/plugins/features/analyze.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/features/analyze.js rename to packages/fes-builder-webpack/src/plugins/features/analyze.js diff --git a/packages/fes-build-webpack/src/plugins/features/chainWebpack.js b/packages/fes-builder-webpack/src/plugins/features/chainWebpack.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/features/chainWebpack.js rename to packages/fes-builder-webpack/src/plugins/features/chainWebpack.js diff --git a/packages/fes-build-webpack/src/plugins/features/copy.js b/packages/fes-builder-webpack/src/plugins/features/copy.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/features/copy.js rename to packages/fes-builder-webpack/src/plugins/features/copy.js diff --git a/packages/fes-build-webpack/src/plugins/features/cssLoader.js b/packages/fes-builder-webpack/src/plugins/features/cssLoader.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/features/cssLoader.js rename to packages/fes-builder-webpack/src/plugins/features/cssLoader.js diff --git a/packages/fes-build-webpack/src/plugins/features/devServer.js b/packages/fes-builder-webpack/src/plugins/features/devServer.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/features/devServer.js rename to packages/fes-builder-webpack/src/plugins/features/devServer.js diff --git a/packages/fes-build-webpack/src/plugins/features/devtool.js b/packages/fes-builder-webpack/src/plugins/features/devtool.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/features/devtool.js rename to packages/fes-builder-webpack/src/plugins/features/devtool.js diff --git a/packages/fes-build-webpack/src/plugins/features/exportStatic.js b/packages/fes-builder-webpack/src/plugins/features/exportStatic.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/features/exportStatic.js rename to packages/fes-builder-webpack/src/plugins/features/exportStatic.js diff --git a/packages/fes-build-webpack/src/plugins/features/externals.js b/packages/fes-builder-webpack/src/plugins/features/externals.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/features/externals.js rename to packages/fes-builder-webpack/src/plugins/features/externals.js diff --git a/packages/fes-build-webpack/src/plugins/features/extraBabelPlugins.js b/packages/fes-builder-webpack/src/plugins/features/extraBabelPlugins.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/features/extraBabelPlugins.js rename to packages/fes-builder-webpack/src/plugins/features/extraBabelPlugins.js diff --git a/packages/fes-build-webpack/src/plugins/features/extraBabelPresets.js b/packages/fes-builder-webpack/src/plugins/features/extraBabelPresets.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/features/extraBabelPresets.js rename to packages/fes-builder-webpack/src/plugins/features/extraBabelPresets.js diff --git a/packages/fes-build-webpack/src/plugins/features/extraPostCSSPlugins.js b/packages/fes-builder-webpack/src/plugins/features/extraPostCSSPlugins.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/features/extraPostCSSPlugins.js rename to packages/fes-builder-webpack/src/plugins/features/extraPostCSSPlugins.js diff --git a/packages/fes-build-webpack/src/plugins/features/html.js b/packages/fes-builder-webpack/src/plugins/features/html.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/features/html.js rename to packages/fes-builder-webpack/src/plugins/features/html.js diff --git a/packages/fes-build-webpack/src/plugins/features/lessLoader.js b/packages/fes-builder-webpack/src/plugins/features/lessLoader.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/features/lessLoader.js rename to packages/fes-builder-webpack/src/plugins/features/lessLoader.js diff --git a/packages/fes-build-webpack/src/plugins/features/nodeModulesTransform.js b/packages/fes-builder-webpack/src/plugins/features/nodeModulesTransform.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/features/nodeModulesTransform.js rename to packages/fes-builder-webpack/src/plugins/features/nodeModulesTransform.js diff --git a/packages/fes-build-webpack/src/plugins/features/postcssLoader.js b/packages/fes-builder-webpack/src/plugins/features/postcssLoader.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/features/postcssLoader.js rename to packages/fes-builder-webpack/src/plugins/features/postcssLoader.js diff --git a/packages/fes-build-webpack/src/plugins/features/vueLoader.js b/packages/fes-builder-webpack/src/plugins/features/vueLoader.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/features/vueLoader.js rename to packages/fes-builder-webpack/src/plugins/features/vueLoader.js diff --git a/packages/fes-build-webpack/src/plugins/registerBuilder.js b/packages/fes-builder-webpack/src/plugins/registerBuilder.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/registerBuilder.js rename to packages/fes-builder-webpack/src/plugins/registerBuilder.js diff --git a/packages/fes-build-webpack/src/plugins/registerMethods.js b/packages/fes-builder-webpack/src/plugins/registerMethods.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/registerMethods.js rename to packages/fes-builder-webpack/src/plugins/registerMethods.js diff --git a/packages/fes-build-webpack/src/plugins/registerType.js b/packages/fes-builder-webpack/src/plugins/registerType.js similarity index 100% rename from packages/fes-build-webpack/src/plugins/registerType.js rename to packages/fes-builder-webpack/src/plugins/registerType.js diff --git a/packages/fes-builder-webpack/src/utils/constants.js b/packages/fes-builder-webpack/src/utils/constants.js new file mode 100644 index 00000000..64cace3c --- /dev/null +++ b/packages/fes-builder-webpack/src/utils/constants.js @@ -0,0 +1,4 @@ +import { winPath } from '@fesjs/utils'; +import { dirname } from 'path'; + +export const runtimePath = winPath(dirname(require.resolve('@fesjs/runtime/package.json'))); diff --git a/packages/fes-builder-webpack/src/utils/generateExports.js b/packages/fes-builder-webpack/src/utils/generateExports.js new file mode 100644 index 00000000..bb5d0a94 --- /dev/null +++ b/packages/fes-builder-webpack/src/utils/generateExports.js @@ -0,0 +1,30 @@ +import { lodash, winPath } from '@fesjs/utils'; +import assert from 'assert'; +import path from 'path'; + +const reserveLibrarys = ['fes']; // reserve library +// todo 插件导出内容冲突问题待解决 +const reserveExportsNames = ['Link', 'NavLink', 'Redirect', 'dynamic', 'withRouter', 'Route']; + +export default function generateExports(basePath, { item, fesExportsHook }) { + assert(item.source, 'source should be supplied.'); + const source = path.relative(path.basename(basePath), item.source); + assert(item.exportAll || item.specifiers, 'exportAll or specifiers should be supplied.'); + assert(!reserveLibrarys.includes(source), `${source} is reserve library, Please don't use it.`); + if (item.exportAll) { + return `export * from '${winPath(source)}';`; + } + assert(Array.isArray(item.specifiers), `specifiers should be Array, but got ${item.specifiers.toString()}.`); + const specifiersStrArr = item.specifiers.map((specifier) => { + if (typeof specifier === 'string') { + assert(!reserveExportsNames.includes(specifier), `${specifier} is reserve name, you can use 'exported' to set alias.`); + assert(!fesExportsHook[specifier], `${specifier} is Defined, you can use 'exported' to set alias.`); + fesExportsHook[specifier] = true; + return specifier; + } + assert(lodash.isPlainObject(specifier), `Configure item context should be Plain Object, but got ${specifier}.`); + assert(specifier.local && specifier.exported, 'local and exported should be supplied.'); + return `${specifier.local} as ${specifier.exported}`; + }); + return `export { ${specifiersStrArr.join(', ')} } from '${winPath(source)}';`; +} diff --git a/packages/fes-build-webpack/types.d.ts b/packages/fes-builder-webpack/types.d.ts similarity index 100% rename from packages/fes-build-webpack/types.d.ts rename to packages/fes-builder-webpack/types.d.ts diff --git a/packages/fes-compiler/src/service/utils/pluginUtils.js b/packages/fes-compiler/src/service/utils/pluginUtils.js index 4c4a0f73..87d185a5 100644 --- a/packages/fes-compiler/src/service/utils/pluginUtils.js +++ b/packages/fes-compiler/src/service/utils/pluginUtils.js @@ -5,7 +5,7 @@ import { PluginType } from '../enums'; const RE = { [PluginType.plugin]: /^(@fesjs\/|@webank\/fes-|fes-)plugin-/, - [PluginType.preset]: /^(@fesjs\/|@webank\/fes-|fes-)(preset|build)-/, + [PluginType.preset]: /^(@fesjs\/|@webank\/fes-|fes-)(preset|builder)-/, }; export function isPluginOrPreset(type, name) { @@ -120,10 +120,10 @@ export function resolvePresets(opts) { if (b.id === '@fesjs/preset-built-in') { return 1; } - if (/^(@fesjs\/|@webank\/fes-|fes-)build-/.test(a.id)) { + if (/^(@fesjs\/|@webank\/fes-|fes-)builder-/.test(a.id)) { return -1; } - if (/^(@fesjs\/|@webank\/fes-|fes-)build-/.test(b.id)) { + if (/^(@fesjs\/|@webank\/fes-|fes-)builder-/.test(b.id)) { return 1; } return 0; diff --git a/packages/fes-plugin-qiankun/examples/micro/package.json b/packages/fes-plugin-qiankun/examples/micro/package.json index 05012303..45df02a0 100644 --- a/packages/fes-plugin-qiankun/examples/micro/package.json +++ b/packages/fes-plugin-qiankun/examples/micro/package.json @@ -44,7 +44,7 @@ }, "dependencies": { "@fesjs/fes": "^2.0.0", - "@fesjs/build-webpack": "^1.0.0", + "@fesjs/builder-webpack": "^1.0.0", "vue": "^3.0.5", "@fesjs/fes-design": "^0.1.10" }, diff --git a/packages/fes-plugin-qiankun/examples/vite-main/.fes.js b/packages/fes-plugin-qiankun/examples/vite-main/.fes.js index d5d77e2b..9789c5c2 100644 --- a/packages/fes-plugin-qiankun/examples/vite-main/.fes.js +++ b/packages/fes-plugin-qiankun/examples/vite-main/.fes.js @@ -41,6 +41,6 @@ export default { require.resolve('../../../fes-plugin-qiankun/lib'), ], presets: [ - require.resolve('../../../fes-build-vite/lib'), + require.resolve('../../../fes-builder-vite/lib'), ] }; diff --git a/packages/fes-plugin-qiankun/examples/webpack-main/.fes.js b/packages/fes-plugin-qiankun/examples/webpack-main/.fes.js index 7182afcf..e7fc5d91 100644 --- a/packages/fes-plugin-qiankun/examples/webpack-main/.fes.js +++ b/packages/fes-plugin-qiankun/examples/webpack-main/.fes.js @@ -39,6 +39,6 @@ export default { require.resolve('../../../fes-plugin-qiankun/lib'), ], presets: [ - require.resolve('../../../fes-build-webpack/lib'), + require.resolve('../../../fes-builder-webpack/lib'), ] }; diff --git a/packages/fes-template-h5/package.json b/packages/fes-template-h5/package.json index 582cbbdc..a307d274 100644 --- a/packages/fes-template-h5/package.json +++ b/packages/fes-template-h5/package.json @@ -47,7 +47,7 @@ "@fesjs/fes": "^2.0.0", "@fesjs/plugin-icon": "^2.0.0", "@fesjs/plugin-request": "^2.0.0", - "@fesjs/build-webpack": "^1.0.0", + "@fesjs/builder-webpack": "^1.0.0", "vue": "^3.2.2" }, "private": true diff --git a/packages/fes-template-vite/package.json b/packages/fes-template-vite/package.json index 72e53db6..62749042 100644 --- a/packages/fes-template-vite/package.json +++ b/packages/fes-template-vite/package.json @@ -58,7 +58,7 @@ "@fesjs/plugin-windicss": "^2.0.0", "@fesjs/plugin-pinia": "^2.0.0", "@fesjs/fes-design": "^0.3.3", - "@fesjs/build-vite": "^1.0.0", + "@fesjs/builder-vite": "^1.0.0", "vue": "^3.0.5", "vuex": "^4.0.0", "pinia": "^2.0.11" diff --git a/packages/fes-template/.fes.js b/packages/fes-template/.fes.js index 52b7e24c..a1aad181 100644 --- a/packages/fes-template/.fes.js +++ b/packages/fes-template/.fes.js @@ -93,6 +93,6 @@ export default { languages: ['javascript', 'typescript', 'html', 'json'] }, presets: [ - require.resolve('../fes-build-webpack/lib'), + require.resolve('../fes-builder-webpack/lib'), ] };