From a8ce595b303991c03802e093687617879045bd81 Mon Sep 17 00:00:00 2001 From: wanchun <445436867@qq.com> Date: Fri, 25 Aug 2023 18:05:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20plugin-layout=E4=B8=8D=E5=BC=BA?= =?UTF-8?q?=E4=BE=9D=E8=B5=96plugin-access?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fes-plugin-layout/src/index.js | 16 ++ .../{pluginAccess.js => pluginAccess.js.tpl} | 10 +- .../runtime/{runtime.js => runtime.js.tpl} | 5 +- pnpm-lock.yaml | 140 +++--------------- 4 files changed, 49 insertions(+), 122 deletions(-) rename packages/fes-plugin-layout/src/runtime/helpers/{pluginAccess.js => pluginAccess.js.tpl} (87%) rename packages/fes-plugin-layout/src/runtime/{runtime.js => runtime.js.tpl} (93%) diff --git a/packages/fes-plugin-layout/src/index.js b/packages/fes-plugin-layout/src/index.js index a1df5923..999ca432 100644 --- a/packages/fes-plugin-layout/src/index.js +++ b/packages/fes-plugin-layout/src/index.js @@ -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({ namespace, path: join(__dirname, 'runtime'), diff --git a/packages/fes-plugin-layout/src/runtime/helpers/pluginAccess.js b/packages/fes-plugin-layout/src/runtime/helpers/pluginAccess.js.tpl similarity index 87% rename from packages/fes-plugin-layout/src/runtime/helpers/pluginAccess.js rename to packages/fes-plugin-layout/src/runtime/helpers/pluginAccess.js.tpl index 23f52022..a9fcf776 100644 --- a/packages/fes-plugin-layout/src/runtime/helpers/pluginAccess.js +++ b/packages/fes-plugin-layout/src/runtime/helpers/pluginAccess.js.tpl @@ -1,4 +1,4 @@ -// eslint-disable-next-line +{{#HAS_PLUGIN_ACCESS}} import { hasAccessSync } from '../../plugin-access/core'; if (!hasAccessSync) { @@ -32,3 +32,11 @@ export const transform = (menus) => return menu; }) .filter(Boolean); + +{{/HAS_PLUGIN_ACCESS}} + +{{^HAS_PLUGIN_ACCESS}} + +export const transform = (menus) => menus; + +{{/HAS_PLUGIN_ACCESS}} \ No newline at end of file diff --git a/packages/fes-plugin-layout/src/runtime/runtime.js b/packages/fes-plugin-layout/src/runtime/runtime.js.tpl similarity index 93% rename from packages/fes-plugin-layout/src/runtime/runtime.js rename to packages/fes-plugin-layout/src/runtime/runtime.js.tpl index 7f604de5..e1890177 100644 --- a/packages/fes-plugin-layout/src/runtime/runtime.js +++ b/packages/fes-plugin-layout/src/runtime/runtime.js.tpl @@ -1,6 +1,5 @@ -// eslint-disable-next-line import/extensions +{{#HAS_PLUGIN_ACCESS}} import { access as accessApi } from '../plugin-access/core'; -// eslint-disable-next-line import/extensions import getConfig from './helpers/getConfig'; if (!accessApi) { @@ -42,3 +41,5 @@ export const access = (memo) => { ...memo, }; }; + +{{/HAS_PLUGIN_ACCESS}} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cf0b86bc..e25cf9b7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,9 +1,5 @@ lockfileVersion: '6.0' -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false - importers: .: @@ -236,7 +232,7 @@ importers: version: 6.7.3(webpack@5.87.0) css-minimizer-webpack-plugin: 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: specifier: ^11.1.1 version: 11.1.1 @@ -275,13 +271,13 @@ importers: version: 3.3.2(webpack@5.87.0) terser-webpack-plugin: 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: specifier: ^17.0.1 version: 17.0.1(vue@3.2.47)(webpack@5.87.0) webpack: specifier: ^5.87.0 - version: 5.87.0 + version: 5.87.0(@swc/core@1.3.49) webpack-5-chain: specifier: ^8.0.1 version: 8.0.1 @@ -4808,7 +4804,7 @@ packages: '@babel/core': 7.21.3 find-cache-dir: 3.3.2 schema-utils: 4.0.1 - webpack: 5.87.0 + webpack: 5.87.0(@swc/core@1.3.49) dev: false /babel-plugin-istanbul@6.1.1: @@ -5718,7 +5714,7 @@ packages: normalize-path: 3.0.0 schema-utils: 4.0.1 serialize-javascript: 6.0.1 - webpack: 5.87.0 + webpack: 5.87.0(@swc/core@1.3.49) dev: false /core-js-compat@3.30.1: @@ -5825,7 +5821,7 @@ packages: postcss-modules-values: 4.0.0(postcss@8.4.21) postcss-value-parser: 4.2.0 semver: 7.5.0 - webpack: 5.87.0 + webpack: 5.87.0(@swc/core@1.3.49) dev: false /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) 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: resolution: {integrity: sha512-wPpOYtnsVontu2mODhA19JrqWxNsfdatRKd64kmpRbQgh1KtItko5sTnEpPdpSaJszTOhEMlF/RPz28qj4HqhQ==} dependencies: @@ -8007,7 +7969,7 @@ packages: lodash: 4.17.21 pretty-error: 4.0.0 tapable: 2.2.0 - webpack: 5.87.0 + webpack: 5.87.0(@swc/core@1.3.49) dev: false /html-webpack-tags-plugin@3.0.0: @@ -9406,7 +9368,7 @@ packages: dependencies: klona: 2.0.6 less: 4.1.3 - webpack: 5.87.0 + webpack: 5.87.0(@swc/core@1.3.49) dev: false /less@4.1.3: @@ -9826,7 +9788,7 @@ packages: webpack: ^5.0.0 dependencies: schema-utils: 4.0.1 - webpack: 5.87.0 + webpack: 5.87.0(@swc/core@1.3.49) dev: false /minimalistic-assert@1.0.1: @@ -9927,7 +9889,7 @@ packages: dependencies: loader-utils: 2.0.4 monaco-editor: 0.36.1 - webpack: 5.87.0 + webpack: 5.87.0(@swc/core@1.3.49) dev: false /monaco-editor@0.36.1: @@ -10654,7 +10616,7 @@ packages: klona: 2.0.6 postcss: 8.4.21 semver: 7.5.0 - webpack: 5.87.0 + webpack: 5.87.0(@swc/core@1.3.49) dev: false /postcss-merge-longhand@6.0.0(postcss@8.4.21): @@ -11479,7 +11441,7 @@ packages: klona: 2.0.6 neo-async: 2.6.2 sass: 1.32.11 - webpack: 5.87.0 + webpack: 5.87.0(@swc/core@1.3.49) dev: false /sass@1.32.11: @@ -12144,7 +12106,7 @@ packages: peerDependencies: webpack: ^5.0.0 dependencies: - webpack: 5.87.0 + webpack: 5.87.0(@swc/core@1.3.49) dev: false /stylehacks@6.0.0(postcss@8.4.21): @@ -12288,30 +12250,6 @@ packages: webpack: 5.87.0(@swc/core@1.3.49) 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: resolution: {integrity: sha512-QI5g1E/ef7d+PsDifb+a6nnVgC4F22Bg6T0xrBrz6iloVB4PUkkunp6V8nzoOOZJIzjWVdAGqCdlKlhLq/TbIA==} engines: {node: '>=10'} @@ -13060,7 +12998,7 @@ packages: hash-sum: 2.0.0 loader-utils: 2.0.4 vue: 3.2.47 - webpack: 5.87.0 + webpack: 5.87.0(@swc/core@1.3.49) dev: false /vue-router@4.1.6(vue@3.2.47): @@ -13205,7 +13143,7 @@ packages: mime-types: 2.1.35 range-parser: 1.2.1 schema-utils: 4.0.1 - webpack: 5.87.0 + webpack: 5.87.0(@swc/core@1.3.49) dev: false /webpack-dev-server@4.8.1(webpack@5.87.0): @@ -13246,7 +13184,7 @@ packages: serve-index: 1.9.1 sockjs: 0.3.24 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) ws: 8.13.0 transitivePeerDependencies: @@ -13265,46 +13203,6 @@ packages: resolution: {integrity: sha512-5tyDlKLqPfMqjT3Q9TAqf2YqjwmnUleZwzJi1A5qXnlBCdj2AtOJ6wAWdglTIDOPgOiOrXeBeFcsQ8+aGQ6QbA==} 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): resolution: {integrity: sha512-GOu1tNbQ7p1bDEoFRs2YPcfyGs8xq52yyPBZ3m2VGnXGtV9MxjrkABHm4V9Ia280OefsSLzvbVoXcfLxjKY/Iw==} engines: {node: '>=10.13.0'} @@ -13355,7 +13253,7 @@ packages: consola: 2.15.3 pretty-time: 1.1.0 std-env: 3.3.2 - webpack: 5.87.0 + webpack: 5.87.0(@swc/core@1.3.49) dev: false /websocket-driver@0.7.4: @@ -13775,3 +13673,7 @@ packages: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} dev: true + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false