From 0fac113adec018391bb6c90a6d734f7c8b1e403f Mon Sep 17 00:00:00 2001 From: winixt Date: Tue, 16 Nov 2021 16:45:34 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81pnpm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fes-template/.fes.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/fes-template/.fes.js b/packages/fes-template/.fes.js index 9c036b3d..105c7a30 100644 --- a/packages/fes-template/.fes.js +++ b/packages/fes-template/.fes.js @@ -2,7 +2,6 @@ export default { exportStatic: {}, - base: "/base/", define: { __DEV__: false, }, From 8528e24599f475c5b8912e68c1cd99e3eed88241 Mon Sep 17 00:00:00 2001 From: winixt Date: Tue, 16 Nov 2021 21:24:25 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81pnpm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fes-plugin-access/package.json | 3 +- packages/fes-plugin-access/src/index.js | 4 +- .../fes-plugin-access/src/runtime/core.tpl | 2 +- packages/fes-plugin-locale/src/index.js | 4 +- .../fes-plugin-locale/src/runtime/core.tpl | 2 +- .../fes-plugin-monaco-editor/src/index.js | 17 ++++- .../src/runtime/{editor.vue => editor.tpl} | 2 +- .../src/runtime/loader.tpl | 2 +- packages/fes-plugin-qiankun/src/main/index.js | 5 +- .../src/main/runtime/MicroApp.tpl | 4 +- packages/fes-plugin-request/package.json | 3 +- packages/fes-plugin-request/src/index.js | 2 + .../src/template/request.js | 2 +- .../generateFiles/core/exports/coreExports.js | 3 +- .../core/exports/coreExports.tpl | 2 +- packages/fes-utils/src/index.js | 4 +- packages/fes-utils/src/resolvePkg.js | 6 ++ yarn.lock | 69 +------------------ 18 files changed, 52 insertions(+), 84 deletions(-) rename packages/fes-plugin-monaco-editor/src/runtime/{editor.vue => editor.tpl} (99%) create mode 100644 packages/fes-utils/src/resolvePkg.js diff --git a/packages/fes-plugin-access/package.json b/packages/fes-plugin-access/package.json index 049f015c..6cbb0eb2 100644 --- a/packages/fes-plugin-access/package.json +++ b/packages/fes-plugin-access/package.json @@ -27,10 +27,11 @@ "access": "public" }, "dependencies": { + "@fesjs/utils": "^2.0.2", "lodash-es": "^4.17.15" }, "peerDependencies": { "@fesjs/fes": "^2.0.0", "vue": "^3.0.5" } -} +} \ No newline at end of file diff --git a/packages/fes-plugin-access/src/index.js b/packages/fes-plugin-access/src/index.js index ce27de0b..edc1147c 100644 --- a/packages/fes-plugin-access/src/index.js +++ b/packages/fes-plugin-access/src/index.js @@ -1,5 +1,6 @@ import { readFileSync } from 'fs'; import { join } from 'path'; +import { resolvePkg } from '@fesjs/utils'; const namespace = 'plugin-access'; @@ -32,7 +33,8 @@ export default (api) => { content: Mustache.render( readFileSync(join(__dirname, 'runtime/core.tpl'), 'utf-8'), { - REPLACE_ROLES: JSON.stringify(roles) + REPLACE_ROLES: JSON.stringify(roles), + lodashPath: resolvePkg('lodash-es') } ) }); diff --git a/packages/fes-plugin-access/src/runtime/core.tpl b/packages/fes-plugin-access/src/runtime/core.tpl index 602ef401..08ebe870 100644 --- a/packages/fes-plugin-access/src/runtime/core.tpl +++ b/packages/fes-plugin-access/src/runtime/core.tpl @@ -1,7 +1,7 @@ import { reactive, unref, computed, inject } from "vue"; import createDirective from "./createDirective"; import createComponent from "./createComponent"; -import {isPlainObject} from "lodash-es"; +import {isPlainObject} from "{{{ lodashPath }}}"; const accessKey = Symbol("plugin-access"); diff --git a/packages/fes-plugin-locale/src/index.js b/packages/fes-plugin-locale/src/index.js index 947e53bf..dbc60171 100644 --- a/packages/fes-plugin-locale/src/index.js +++ b/packages/fes-plugin-locale/src/index.js @@ -1,5 +1,6 @@ import { readFileSync } from 'fs'; import { join } from 'path'; +import { resolvePkg } from '@fesjs/utils'; import { getLocalesJSON } from './utils'; const namespace = 'plugin-locale'; @@ -64,7 +65,8 @@ export default (api) => { legacy: userConfig.legacy }, null, 2), BASE_NAVIGATOR: userConfig.baseNavigator, - SHARE: userConfig.share + SHARE: userConfig.share, + VUE_I18N_PATH: resolvePkg('vue-i18n') } ) }); diff --git a/packages/fes-plugin-locale/src/runtime/core.tpl b/packages/fes-plugin-locale/src/runtime/core.tpl index e6914861..f07929bc 100644 --- a/packages/fes-plugin-locale/src/runtime/core.tpl +++ b/packages/fes-plugin-locale/src/runtime/core.tpl @@ -6,7 +6,7 @@ // 其他插件可以运行时修改配置 // 所有插件使用一个语言和配置 import { isRef } from 'vue'; -import { createI18n, useI18n } from 'vue-i18n'; +import { createI18n, useI18n } from '{{{ VUE_I18N_PATH }}}'; import { plugin, ApplyPluginsType } from "@@/core/coreExports"; import SelectLang from "./views/SelectLang"; diff --git a/packages/fes-plugin-monaco-editor/src/index.js b/packages/fes-plugin-monaco-editor/src/index.js index 9fed1c1b..80a68b1f 100644 --- a/packages/fes-plugin-monaco-editor/src/index.js +++ b/packages/fes-plugin-monaco-editor/src/index.js @@ -1,5 +1,6 @@ import { readFileSync } from 'fs'; import { join } from 'path'; +import { resolvePkg } from '@fesjs/utils'; const namespace = 'plugin-monaco-editor'; @@ -30,6 +31,7 @@ export default (api) => { const absRuntimeFilePath = join(namespace, 'runtime.js'); const absLoaderFilePath = join(namespace, 'loader.js'); + const absEditorFilePath = join(namespace, 'editor.vue'); api.onGenerateFiles(() => { // 文件写出 @@ -52,7 +54,20 @@ export default (api) => { api.writeTmpFile({ path: absLoaderFilePath, content: Mustache.render( - readFileSync(join(__dirname, 'runtime/loader.tpl'), 'utf-8') + readFileSync(join(__dirname, 'runtime/loader.tpl'), 'utf-8'), + { + MONACO_EDITOR: resolvePkg('monaco-editor') + } + ) + }); + + api.writeTmpFile({ + path: absEditorFilePath, + content: Mustache.render( + readFileSync(join(__dirname, 'runtime/editor.tpl'), 'utf-8'), + { + LODASH_ES: resolvePkg('lodash-es') + } ) }); diff --git a/packages/fes-plugin-monaco-editor/src/runtime/editor.vue b/packages/fes-plugin-monaco-editor/src/runtime/editor.tpl similarity index 99% rename from packages/fes-plugin-monaco-editor/src/runtime/editor.vue rename to packages/fes-plugin-monaco-editor/src/runtime/editor.tpl index 77ffb5eb..44ca7d88 100644 --- a/packages/fes-plugin-monaco-editor/src/runtime/editor.vue +++ b/packages/fes-plugin-monaco-editor/src/runtime/editor.tpl @@ -5,7 +5,7 @@ import { computed, ref, watch, onMounted, onBeforeUnmount } from 'vue'; -import { merge, debounce } from 'lodash-es'; +import { merge, debounce } from '{{{ LODASH_ES }}}'; // eslint-disable-next-line import monaco from './loader'; diff --git a/packages/fes-plugin-monaco-editor/src/runtime/loader.tpl b/packages/fes-plugin-monaco-editor/src/runtime/loader.tpl index 0c469cc3..0d206fe1 100644 --- a/packages/fes-plugin-monaco-editor/src/runtime/loader.tpl +++ b/packages/fes-plugin-monaco-editor/src/runtime/loader.tpl @@ -1,4 +1,4 @@ -import * as monaco from 'monaco-editor'; +import * as monaco from '{{{ MONACO_EDITOR }}}'; import defaultTheme from './theme/default'; // 默认主题 diff --git a/packages/fes-plugin-qiankun/src/main/index.js b/packages/fes-plugin-qiankun/src/main/index.js index 3f4b035e..d31b70bd 100644 --- a/packages/fes-plugin-qiankun/src/main/index.js +++ b/packages/fes-plugin-qiankun/src/main/index.js @@ -1,5 +1,6 @@ import { readFileSync, existsSync } from 'fs'; import { join } from 'path'; +import { resolvePkg } from '@fesjs/utils'; import { defaultMainRootId, defaultHistoryType, @@ -58,7 +59,9 @@ export default function (api) { 'models/qiankunStateForMicro.js' ) ) - ) + ), + QIANKUN: resolvePkg('qiankun'), + LODASH_ES: resolvePkg('lodash-es') } ) }); diff --git a/packages/fes-plugin-qiankun/src/main/runtime/MicroApp.tpl b/packages/fes-plugin-qiankun/src/main/runtime/MicroApp.tpl index 512f38e7..0765c82a 100644 --- a/packages/fes-plugin-qiankun/src/main/runtime/MicroApp.tpl +++ b/packages/fes-plugin-qiankun/src/main/runtime/MicroApp.tpl @@ -7,8 +7,8 @@ import { onBeforeUnmount, onMounted, } from "vue"; -import { loadMicroApp } from "qiankun"; -import {mergeWith} from "lodash-es"; +import { loadMicroApp } from "{{{QIANKUN}}}"; +import {mergeWith} from "{{{LODASH_ES}}}"; // eslint-disable-next-line import/extensions import { getMasterOptions } from "./masterOptions"; import { onBeforeRouteLeave } from "@@/core/coreExports"; diff --git a/packages/fes-plugin-request/package.json b/packages/fes-plugin-request/package.json index 03963b3d..771f316e 100644 --- a/packages/fes-plugin-request/package.json +++ b/packages/fes-plugin-request/package.json @@ -31,7 +31,8 @@ "vue": "^3.0.5" }, "dependencies": { + "@fesjs/utils": "^2.0.2", "@fesjs/compiler": "^2.0.2", "axios": "0.21.1" } -} +} \ No newline at end of file diff --git a/packages/fes-plugin-request/src/index.js b/packages/fes-plugin-request/src/index.js index ed17d778..d8407a19 100644 --- a/packages/fes-plugin-request/src/index.js +++ b/packages/fes-plugin-request/src/index.js @@ -1,6 +1,7 @@ import { Logger } from '@fesjs/compiler'; import { readFileSync } from 'fs'; import { join } from 'path'; +import { resolvePkg } from '@fesjs/utils'; const logger = new Logger('fes:plugin-request'); @@ -44,6 +45,7 @@ export default (api) => { content: requestTemplate .replace('REPLACE_DATA_FIELD', JSON.stringify(dataField)) .replace('REPLACE_BASE', base || '') + .replace('AXIOS_PATH', resolvePkg('axios')) }); }); diff --git a/packages/fes-plugin-request/src/template/request.js b/packages/fes-plugin-request/src/template/request.js index da9e4689..db251ee1 100644 --- a/packages/fes-plugin-request/src/template/request.js +++ b/packages/fes-plugin-request/src/template/request.js @@ -1,4 +1,4 @@ -import axios from 'axios'; +import axios from 'AXIOS_PATH'; import { ApplyPluginsType, plugin } from '@fesjs/fes'; import { ref } from 'vue'; import scheduler from './scheduler'; diff --git a/packages/fes-preset-built-in/src/plugins/generateFiles/core/exports/coreExports.js b/packages/fes-preset-built-in/src/plugins/generateFiles/core/exports/coreExports.js index 926fbf93..66eb0e06 100644 --- a/packages/fes-preset-built-in/src/plugins/generateFiles/core/exports/coreExports.js +++ b/packages/fes-preset-built-in/src/plugins/generateFiles/core/exports/coreExports.js @@ -1,6 +1,7 @@ import { readFileSync } from 'fs'; import { join } from 'path'; import generateExports from '../../../../utils/generateExports'; +import { runtimePath } from '../../../../utils/constants'; export default function (api) { api.onGenerateFiles(async () => { @@ -21,7 +22,7 @@ export default function (api) { const tpl = readFileSync(join(__dirname, './coreExports.tpl'), 'utf-8'); api.writeTmpFile({ path: absoluteFilePath, - content: tpl.replace('CORE_EXPORTS', content) + content: tpl.replace('CORE_EXPORTS', content).replace('RUNTIME_PATH', runtimePath) }); }); } diff --git a/packages/fes-preset-built-in/src/plugins/generateFiles/core/exports/coreExports.tpl b/packages/fes-preset-built-in/src/plugins/generateFiles/core/exports/coreExports.tpl index 2d0545ff..e2577c64 100644 --- a/packages/fes-preset-built-in/src/plugins/generateFiles/core/exports/coreExports.tpl +++ b/packages/fes-preset-built-in/src/plugins/generateFiles/core/exports/coreExports.tpl @@ -12,6 +12,6 @@ export { createRouter, Plugin, ApplyPluginsType -} from '@fesjs/runtime'; +} from 'RUNTIME_PATH'; CORE_EXPORTS \ No newline at end of file diff --git a/packages/fes-utils/src/index.js b/packages/fes-utils/src/index.js index 2be91978..816691c2 100644 --- a/packages/fes-utils/src/index.js +++ b/packages/fes-utils/src/index.js @@ -18,6 +18,7 @@ import Mustache from 'mustache'; import Generator from './Generator'; import winPath from './winPath'; import delay from './delay'; +import resolvePkg from './resolvePkg'; import compatESModuleRequire from './compatESModuleRequire'; import cleanRequireCache from './cleanRequireCache'; import parseRequireDeps from './parseRequireDeps'; @@ -49,5 +50,6 @@ export { compatESModuleRequire, cleanRequireCache, parseRequireDeps, - mergeConfig + mergeConfig, + resolvePkg }; diff --git a/packages/fes-utils/src/resolvePkg.js b/packages/fes-utils/src/resolvePkg.js new file mode 100644 index 00000000..33a4d3e5 --- /dev/null +++ b/packages/fes-utils/src/resolvePkg.js @@ -0,0 +1,6 @@ +import { dirname } from 'path'; +import winPath from './winPath'; + +const resolvePkg = pkgName => winPath(dirname(require.resolve(`${pkgName}/package.json`))); + +export default resolvePkg; diff --git a/yarn.lock b/yarn.lock index df26ed8f..70de20ac 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2966,17 +2966,6 @@ html-tags "^3.1.0" svg-tags "^1.0.0" -"@vue/compiler-core@3.2.11": - version "3.2.11" - resolved "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.2.11.tgz#10af3777dba303ee7aae668029f131cb90391bee" - integrity sha512-bcbsLx5XyQg8WDDEGwmpX0BfEfv82wIs9fWFelpyVhNRGMaABvUTalYINyfhVT+jOqNaD4JBhJiVKd/8TmsHWg== - dependencies: - "@babel/parser" "^7.15.0" - "@babel/types" "^7.15.0" - "@vue/shared" "3.2.11" - estree-walker "^2.0.2" - source-map "^0.6.1" - "@vue/compiler-core@3.2.2": version "3.2.2" resolved "http://10.107.103.115:8001/@vue/compiler-core/download/@vue/compiler-core-3.2.2.tgz#8d3e29f129579ed9b14f48af735fd8d95f248504" @@ -2988,14 +2977,6 @@ estree-walker "^2.0.1" source-map "^0.6.1" -"@vue/compiler-dom@3.2.11": - version "3.2.11" - resolved "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.2.11.tgz#d066f8e1f1812b4e881593819ade0fe6d654c776" - integrity sha512-DNvhUHI/1Hn0/+ZYDYGAuDGasUm+XHKC3FE4GqkNCTO/fcLaJMRg/7eT1m1lkc7jPffUwwfh1rZru5mwzOjrNw== - dependencies: - "@vue/compiler-core" "3.2.11" - "@vue/shared" "3.2.11" - "@vue/compiler-dom@3.2.2": version "3.2.2" resolved "http://10.107.103.115:8001/@vue/compiler-dom/download/@vue/compiler-dom-3.2.2.tgz#26e198498746c53047c3744d26fc95e670692ab7" @@ -3027,38 +3008,6 @@ postcss-selector-parser "^6.0.4" source-map "^0.6.1" -"@vue/compiler-sfc@^3.0.4": - version "3.2.11" - resolved "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.2.11.tgz#628fa12238760d9b9b339ac2e125a759224fadbf" - integrity sha512-cUIaS8mgJrQ6yucj2AupWAwBRITK3W/a8wCOn9g5fJGtOl8h4APY8vN3lzP8HIJDyEeRF3I8SfRhL+oX97kSnw== - dependencies: - "@babel/parser" "^7.15.0" - "@babel/types" "^7.15.0" - "@types/estree" "^0.0.48" - "@vue/compiler-core" "3.2.11" - "@vue/compiler-dom" "3.2.11" - "@vue/compiler-ssr" "3.2.11" - "@vue/ref-transform" "3.2.11" - "@vue/shared" "3.2.11" - consolidate "^0.16.0" - estree-walker "^2.0.2" - hash-sum "^2.0.0" - lru-cache "^5.1.1" - magic-string "^0.25.7" - merge-source-map "^1.1.0" - postcss "^8.1.10" - postcss-modules "^4.0.0" - postcss-selector-parser "^6.0.4" - source-map "^0.6.1" - -"@vue/compiler-ssr@3.2.11": - version "3.2.11" - resolved "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.2.11.tgz#702cef3429651645bdbe09fe5962803b5a621abb" - integrity sha512-+ptAdUlFDij+Z0VGCbRRkxQlNev5LkbZAntvkxrFjc08CTMhZmiV4Js48n2hAmuSXaKNEpmGkDGU26c/vf1+xw== - dependencies: - "@vue/compiler-dom" "3.2.11" - "@vue/shared" "3.2.11" - "@vue/compiler-ssr@3.2.2": version "3.2.2" resolved "http://10.107.103.115:8001/@vue/compiler-ssr/download/@vue/compiler-ssr-3.2.2.tgz#633bb8e01f00a969c35ca12db32be7fe4c7185a9" @@ -3079,17 +3028,6 @@ dependencies: "@vue/shared" "3.2.2" -"@vue/ref-transform@3.2.11": - version "3.2.11" - resolved "https://registry.npmjs.org/@vue/ref-transform/-/ref-transform-3.2.11.tgz#4d282b9570d1485a73e7bf5d57cce27b4a7aa690" - integrity sha512-7rX0YsfYb7+1PeKPME1tQyUQcQgt0sIXRRnPD1Vw8Zs2KIo90YLy9CrvwalcRCxGw0ScsjBEhVjJtWIT79TElg== - dependencies: - "@babel/parser" "^7.15.0" - "@vue/compiler-core" "3.2.11" - "@vue/shared" "3.2.11" - estree-walker "^2.0.2" - magic-string "^0.25.7" - "@vue/runtime-core@3.2.2": version "3.2.2" resolved "http://10.107.103.115:8001/@vue/runtime-core/download/@vue/runtime-core-3.2.2.tgz#b9a7250783de19dd8dd6febf008084b0f9144586" @@ -3115,11 +3053,6 @@ "@vue/compiler-ssr" "3.2.2" "@vue/shared" "3.2.2" -"@vue/shared@3.2.11": - version "3.2.11" - resolved "https://registry.npmjs.org/@vue/shared/-/shared-3.2.11.tgz#01899f54949caf1ac241de397bd17069632574de" - integrity sha512-ovfXAsSsCvV9JVceWjkqC/7OF5HbgLOtCWjCIosmPGG8lxbPuavhIxRH1dTx4Dg9xLgRTNLvI3pVxG4ItQZekg== - "@vue/shared@3.2.2", "@vue/shared@^3.2.2": version "3.2.2" resolved "http://10.107.103.115:8001/@vue/shared/download/@vue/shared-3.2.2.tgz#6104185ebd57af5a14ac51c1f491b2205fc24054" @@ -6154,7 +6087,7 @@ estree-walker@^1.0.1: resolved "http://10.107.103.115:8001/estree-walker/download/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700" integrity sha1-MbxdYSyWtwQQa0d+bdXYqhOMtwA= -estree-walker@^2.0.1, estree-walker@^2.0.2: +estree-walker@^2.0.1: version "2.0.2" resolved "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac" integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w== From 67657ab9e32969c62f80fcfcdf30dbf8a0d3e516 Mon Sep 17 00:00:00 2001 From: winixt Date: Tue, 16 Nov 2021 22:01:26 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=20vue-i18n=20?= =?UTF-8?q?=E5=BC=95=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fes-plugin-locale/src/index.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/fes-plugin-locale/src/index.js b/packages/fes-plugin-locale/src/index.js index dbc60171..d7714596 100644 --- a/packages/fes-plugin-locale/src/index.js +++ b/packages/fes-plugin-locale/src/index.js @@ -10,10 +10,6 @@ export default (api) => { utils: { Mustache } } = api; - api.chainWebpack((memo) => { - memo.resolve.alias.set('vue-i18n', 'vue-i18n/dist/vue-i18n.esm-bundler.js'); - }); - api.describe({ key: 'locale', config: {