feat: plugin-layout不强依赖plugin-access (#209)

This commit is contained in:
听海 2023-08-28 10:24:52 +08:00 committed by GitHub
parent a08d9ddcb1
commit 6759ebfe21
4 changed files with 49 additions and 122 deletions

View File

@ -57,6 +57,22 @@ export default (api) => {
}), }),
}); });
const HAS_PLUGIN_ACCESS = api.hasPlugins(['@fesjs/plugin-access']);
api.writeTmpFile({
path: join(namespace, 'helpers/pluginAccess.js'),
content: Mustache.render(readFileSync(join(__dirname, 'runtime/helpers/pluginAccess.js.tpl'), 'utf-8'), {
HAS_PLUGIN_ACCESS,
}),
});
api.writeTmpFile({
path: absRuntimeFilePath,
content: Mustache.render(readFileSync(join(__dirname, 'runtime/runtime.js.tpl'), 'utf-8'), {
HAS_PLUGIN_ACCESS,
}),
});
api.copyTmpFiles({ api.copyTmpFiles({
namespace, namespace,
path: join(__dirname, 'runtime'), path: join(__dirname, 'runtime'),

View File

@ -1,4 +1,4 @@
// eslint-disable-next-line {{#HAS_PLUGIN_ACCESS}}
import { hasAccessSync } from '../../plugin-access/core'; import { hasAccessSync } from '../../plugin-access/core';
if (!hasAccessSync) { if (!hasAccessSync) {
@ -32,3 +32,11 @@ export const transform = (menus) =>
return menu; return menu;
}) })
.filter(Boolean); .filter(Boolean);
{{/HAS_PLUGIN_ACCESS}}
{{^HAS_PLUGIN_ACCESS}}
export const transform = (menus) => menus;
{{/HAS_PLUGIN_ACCESS}}

View File

@ -1,6 +1,5 @@
// eslint-disable-next-line import/extensions {{#HAS_PLUGIN_ACCESS}}
import { access as accessApi } from '../plugin-access/core'; import { access as accessApi } from '../plugin-access/core';
// eslint-disable-next-line import/extensions
import getConfig from './helpers/getConfig'; import getConfig from './helpers/getConfig';
if (!accessApi) { if (!accessApi) {
@ -42,3 +41,5 @@ export const access = (memo) => {
...memo, ...memo,
}; };
}; };
{{/HAS_PLUGIN_ACCESS}}

140
pnpm-lock.yaml generated
View File

@ -1,9 +1,5 @@
lockfileVersion: '6.0' lockfileVersion: '6.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
importers: importers:
.: .:
@ -236,7 +232,7 @@ importers:
version: 6.7.3(webpack@5.87.0) version: 6.7.3(webpack@5.87.0)
css-minimizer-webpack-plugin: css-minimizer-webpack-plugin:
specifier: ^5.0.0 specifier: ^5.0.0
version: 5.0.0(webpack@5.87.0) version: 5.0.0(@swc/css@0.0.20)(webpack@5.87.0)
fs-extra: fs-extra:
specifier: ^11.1.1 specifier: ^11.1.1
version: 11.1.1 version: 11.1.1
@ -275,13 +271,13 @@ importers:
version: 3.3.2(webpack@5.87.0) version: 3.3.2(webpack@5.87.0)
terser-webpack-plugin: terser-webpack-plugin:
specifier: ^5.3.6 specifier: ^5.3.6
version: 5.3.7(webpack@5.87.0) version: 5.3.7(@swc/core@1.3.49)(webpack@5.87.0)
vue-loader: vue-loader:
specifier: ^17.0.1 specifier: ^17.0.1
version: 17.0.1(vue@3.2.47)(webpack@5.87.0) version: 17.0.1(vue@3.2.47)(webpack@5.87.0)
webpack: webpack:
specifier: ^5.87.0 specifier: ^5.87.0
version: 5.87.0 version: 5.87.0(@swc/core@1.3.49)
webpack-5-chain: webpack-5-chain:
specifier: ^8.0.1 specifier: ^8.0.1
version: 8.0.1 version: 8.0.1
@ -4808,7 +4804,7 @@ packages:
'@babel/core': 7.21.3 '@babel/core': 7.21.3
find-cache-dir: 3.3.2 find-cache-dir: 3.3.2
schema-utils: 4.0.1 schema-utils: 4.0.1
webpack: 5.87.0 webpack: 5.87.0(@swc/core@1.3.49)
dev: false dev: false
/babel-plugin-istanbul@6.1.1: /babel-plugin-istanbul@6.1.1:
@ -5718,7 +5714,7 @@ packages:
normalize-path: 3.0.0 normalize-path: 3.0.0
schema-utils: 4.0.1 schema-utils: 4.0.1
serialize-javascript: 6.0.1 serialize-javascript: 6.0.1
webpack: 5.87.0 webpack: 5.87.0(@swc/core@1.3.49)
dev: false dev: false
/core-js-compat@3.30.1: /core-js-compat@3.30.1:
@ -5825,7 +5821,7 @@ packages:
postcss-modules-values: 4.0.0(postcss@8.4.21) postcss-modules-values: 4.0.0(postcss@8.4.21)
postcss-value-parser: 4.2.0 postcss-value-parser: 4.2.0
semver: 7.5.0 semver: 7.5.0
webpack: 5.87.0 webpack: 5.87.0(@swc/core@1.3.49)
dev: false dev: false
/css-minimizer-webpack-plugin@5.0.0(@swc/css@0.0.20)(webpack@5.87.0): /css-minimizer-webpack-plugin@5.0.0(@swc/css@0.0.20)(webpack@5.87.0):
@ -5863,40 +5859,6 @@ packages:
webpack: 5.87.0(@swc/core@1.3.49) webpack: 5.87.0(@swc/core@1.3.49)
dev: false dev: false
/css-minimizer-webpack-plugin@5.0.0(webpack@5.87.0):
resolution: {integrity: sha512-1wZ/PYvg+ZKwi5FX6YrvbB31jMAdurS+CmRQLwWCVSlfzJC85l/a6RVICqUHFa+jXyhilfnCyjafzJGbmz5tcA==}
engines: {node: '>= 14.15.0'}
peerDependencies:
'@parcel/css': '*'
'@swc/css': '*'
clean-css: '*'
csso: '*'
esbuild: '*'
lightningcss: '*'
webpack: ^5.0.0
peerDependenciesMeta:
'@parcel/css':
optional: true
'@swc/css':
optional: true
clean-css:
optional: true
csso:
optional: true
esbuild:
optional: true
lightningcss:
optional: true
dependencies:
cssnano: 6.0.0(postcss@8.4.21)
jest-worker: 29.5.0
postcss: 8.4.21
schema-utils: 4.0.1
serialize-javascript: 6.0.1
source-map: 0.6.1
webpack: 5.87.0
dev: false
/css-select@4.3.0: /css-select@4.3.0:
resolution: {integrity: sha512-wPpOYtnsVontu2mODhA19JrqWxNsfdatRKd64kmpRbQgh1KtItko5sTnEpPdpSaJszTOhEMlF/RPz28qj4HqhQ==} resolution: {integrity: sha512-wPpOYtnsVontu2mODhA19JrqWxNsfdatRKd64kmpRbQgh1KtItko5sTnEpPdpSaJszTOhEMlF/RPz28qj4HqhQ==}
dependencies: dependencies:
@ -8007,7 +7969,7 @@ packages:
lodash: 4.17.21 lodash: 4.17.21
pretty-error: 4.0.0 pretty-error: 4.0.0
tapable: 2.2.0 tapable: 2.2.0
webpack: 5.87.0 webpack: 5.87.0(@swc/core@1.3.49)
dev: false dev: false
/html-webpack-tags-plugin@3.0.0: /html-webpack-tags-plugin@3.0.0:
@ -9406,7 +9368,7 @@ packages:
dependencies: dependencies:
klona: 2.0.6 klona: 2.0.6
less: 4.1.3 less: 4.1.3
webpack: 5.87.0 webpack: 5.87.0(@swc/core@1.3.49)
dev: false dev: false
/less@4.1.3: /less@4.1.3:
@ -9826,7 +9788,7 @@ packages:
webpack: ^5.0.0 webpack: ^5.0.0
dependencies: dependencies:
schema-utils: 4.0.1 schema-utils: 4.0.1
webpack: 5.87.0 webpack: 5.87.0(@swc/core@1.3.49)
dev: false dev: false
/minimalistic-assert@1.0.1: /minimalistic-assert@1.0.1:
@ -9927,7 +9889,7 @@ packages:
dependencies: dependencies:
loader-utils: 2.0.4 loader-utils: 2.0.4
monaco-editor: 0.36.1 monaco-editor: 0.36.1
webpack: 5.87.0 webpack: 5.87.0(@swc/core@1.3.49)
dev: false dev: false
/monaco-editor@0.36.1: /monaco-editor@0.36.1:
@ -10654,7 +10616,7 @@ packages:
klona: 2.0.6 klona: 2.0.6
postcss: 8.4.21 postcss: 8.4.21
semver: 7.5.0 semver: 7.5.0
webpack: 5.87.0 webpack: 5.87.0(@swc/core@1.3.49)
dev: false dev: false
/postcss-merge-longhand@6.0.0(postcss@8.4.21): /postcss-merge-longhand@6.0.0(postcss@8.4.21):
@ -11479,7 +11441,7 @@ packages:
klona: 2.0.6 klona: 2.0.6
neo-async: 2.6.2 neo-async: 2.6.2
sass: 1.32.11 sass: 1.32.11
webpack: 5.87.0 webpack: 5.87.0(@swc/core@1.3.49)
dev: false dev: false
/sass@1.32.11: /sass@1.32.11:
@ -12144,7 +12106,7 @@ packages:
peerDependencies: peerDependencies:
webpack: ^5.0.0 webpack: ^5.0.0
dependencies: dependencies:
webpack: 5.87.0 webpack: 5.87.0(@swc/core@1.3.49)
dev: false dev: false
/stylehacks@6.0.0(postcss@8.4.21): /stylehacks@6.0.0(postcss@8.4.21):
@ -12288,30 +12250,6 @@ packages:
webpack: 5.87.0(@swc/core@1.3.49) webpack: 5.87.0(@swc/core@1.3.49)
dev: false dev: false
/terser-webpack-plugin@5.3.7(webpack@5.87.0):
resolution: {integrity: sha512-AfKwIktyP7Cu50xNjXF/6Qb5lBNzYaWpU6YfoX3uZicTx0zTy0stDDCsvjDapKsSDvOeWo5MEq4TmdBy2cNoHw==}
engines: {node: '>= 10.13.0'}
peerDependencies:
'@swc/core': '*'
esbuild: '*'
uglify-js: '*'
webpack: ^5.1.0
peerDependenciesMeta:
'@swc/core':
optional: true
esbuild:
optional: true
uglify-js:
optional: true
dependencies:
'@jridgewell/trace-mapping': 0.3.18
jest-worker: 27.5.1
schema-utils: 3.1.2
serialize-javascript: 6.0.1
terser: 5.16.8
webpack: 5.87.0
dev: false
/terser@5.16.8: /terser@5.16.8:
resolution: {integrity: sha512-QI5g1E/ef7d+PsDifb+a6nnVgC4F22Bg6T0xrBrz6iloVB4PUkkunp6V8nzoOOZJIzjWVdAGqCdlKlhLq/TbIA==} resolution: {integrity: sha512-QI5g1E/ef7d+PsDifb+a6nnVgC4F22Bg6T0xrBrz6iloVB4PUkkunp6V8nzoOOZJIzjWVdAGqCdlKlhLq/TbIA==}
engines: {node: '>=10'} engines: {node: '>=10'}
@ -13060,7 +12998,7 @@ packages:
hash-sum: 2.0.0 hash-sum: 2.0.0
loader-utils: 2.0.4 loader-utils: 2.0.4
vue: 3.2.47 vue: 3.2.47
webpack: 5.87.0 webpack: 5.87.0(@swc/core@1.3.49)
dev: false dev: false
/vue-router@4.1.6(vue@3.2.47): /vue-router@4.1.6(vue@3.2.47):
@ -13205,7 +13143,7 @@ packages:
mime-types: 2.1.35 mime-types: 2.1.35
range-parser: 1.2.1 range-parser: 1.2.1
schema-utils: 4.0.1 schema-utils: 4.0.1
webpack: 5.87.0 webpack: 5.87.0(@swc/core@1.3.49)
dev: false dev: false
/webpack-dev-server@4.8.1(webpack@5.87.0): /webpack-dev-server@4.8.1(webpack@5.87.0):
@ -13246,7 +13184,7 @@ packages:
serve-index: 1.9.1 serve-index: 1.9.1
sockjs: 0.3.24 sockjs: 0.3.24
spdy: 4.0.2 spdy: 4.0.2
webpack: 5.87.0 webpack: 5.87.0(@swc/core@1.3.49)
webpack-dev-middleware: 5.3.3(webpack@5.87.0) webpack-dev-middleware: 5.3.3(webpack@5.87.0)
ws: 8.13.0 ws: 8.13.0
transitivePeerDependencies: transitivePeerDependencies:
@ -13265,46 +13203,6 @@ packages:
resolution: {integrity: sha512-5tyDlKLqPfMqjT3Q9TAqf2YqjwmnUleZwzJi1A5qXnlBCdj2AtOJ6wAWdglTIDOPgOiOrXeBeFcsQ8+aGQ6QbA==} resolution: {integrity: sha512-5tyDlKLqPfMqjT3Q9TAqf2YqjwmnUleZwzJi1A5qXnlBCdj2AtOJ6wAWdglTIDOPgOiOrXeBeFcsQ8+aGQ6QbA==}
dev: false dev: false
/webpack@5.87.0:
resolution: {integrity: sha512-GOu1tNbQ7p1bDEoFRs2YPcfyGs8xq52yyPBZ3m2VGnXGtV9MxjrkABHm4V9Ia280OefsSLzvbVoXcfLxjKY/Iw==}
engines: {node: '>=10.13.0'}
hasBin: true
peerDependencies:
webpack-cli: '*'
peerDependenciesMeta:
webpack-cli:
optional: true
dependencies:
'@types/eslint-scope': 3.7.4
'@types/estree': 1.0.1
'@webassemblyjs/ast': 1.11.6
'@webassemblyjs/wasm-edit': 1.11.6
'@webassemblyjs/wasm-parser': 1.11.6
acorn: 8.8.2
acorn-import-assertions: 1.9.0(acorn@8.8.2)
browserslist: 4.21.5
chrome-trace-event: 1.0.3
enhanced-resolve: 5.15.0
es-module-lexer: 1.3.0
eslint-scope: 5.1.1
events: 3.3.0
glob-to-regexp: 0.4.1
graceful-fs: 4.2.11
json-parse-even-better-errors: 2.3.1
loader-runner: 4.3.0
mime-types: 2.1.35
neo-async: 2.6.2
schema-utils: 3.3.0
tapable: 2.2.0
terser-webpack-plugin: 5.3.7(webpack@5.87.0)
watchpack: 2.4.0
webpack-sources: 3.2.3
transitivePeerDependencies:
- '@swc/core'
- esbuild
- uglify-js
dev: false
/webpack@5.87.0(@swc/core@1.3.49): /webpack@5.87.0(@swc/core@1.3.49):
resolution: {integrity: sha512-GOu1tNbQ7p1bDEoFRs2YPcfyGs8xq52yyPBZ3m2VGnXGtV9MxjrkABHm4V9Ia280OefsSLzvbVoXcfLxjKY/Iw==} resolution: {integrity: sha512-GOu1tNbQ7p1bDEoFRs2YPcfyGs8xq52yyPBZ3m2VGnXGtV9MxjrkABHm4V9Ia280OefsSLzvbVoXcfLxjKY/Iw==}
engines: {node: '>=10.13.0'} engines: {node: '>=10.13.0'}
@ -13355,7 +13253,7 @@ packages:
consola: 2.15.3 consola: 2.15.3
pretty-time: 1.1.0 pretty-time: 1.1.0
std-env: 3.3.2 std-env: 3.3.2
webpack: 5.87.0 webpack: 5.87.0(@swc/core@1.3.49)
dev: false dev: false
/websocket-driver@0.7.4: /websocket-driver@0.7.4:
@ -13775,3 +13673,7 @@ packages:
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
engines: {node: '>=10'} engines: {node: '>=10'}
dev: true dev: true
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false