feat: 支持pnpm

This commit is contained in:
winixt 2021-11-16 21:24:25 +08:00
parent 194246b67a
commit 6fec42a19b
18 changed files with 52 additions and 84 deletions

View File

@ -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"
}
}
}

View File

@ -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')
}
)
});

View File

@ -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");

View File

@ -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')
}
)
});

View File

@ -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";

View File

@ -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')
}
)
});

View File

@ -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';

View File

@ -1,4 +1,4 @@
import * as monaco from 'monaco-editor';
import * as monaco from '{{{ MONACO_EDITOR }}}';
import defaultTheme from './theme/default';
// 默认主题

View File

@ -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')
}
)
});

View File

@ -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";

View File

@ -31,7 +31,8 @@
"vue": "^3.0.5"
},
"dependencies": {
"@fesjs/utils": "^2.0.2",
"@fesjs/compiler": "^2.0.2",
"axios": "0.21.1"
}
}
}

View File

@ -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'))
});
});

View File

@ -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';

View File

@ -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)
});
});
}

View File

@ -12,6 +12,6 @@ export {
createRouter,
Plugin,
ApplyPluginsType
} from '@fesjs/runtime';
} from 'RUNTIME_PATH';
CORE_EXPORTS

View File

@ -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
};

View File

@ -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;

View File

@ -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://127.0.0.1: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://127.0.0.1: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://127.0.0.1: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://127.0.0.1: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://127.0.0.1:8001/@vue/shared/download/@vue/shared-3.2.2.tgz#6104185ebd57af5a14ac51c1f491b2205fc24054"
@ -6154,7 +6087,7 @@ estree-walker@^1.0.1:
resolved "http://127.0.0.1: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==