lcd-router-webpack-plugin 9.0.0-alpha.7 → 9.0.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ declare const _default: any;
2
+ export default _default;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/babel/index.ts"],"names":[],"mappings":";AAGA,wBA8BG"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _helperPluginUtils = require("@babel/helper-plugin-utils");
8
+ var _utils = require("../utils");
9
+ var _default = (0, _helperPluginUtils.declare)((api, options) => {
10
+ api.assertVersion(7);
11
+ const pathService = new _utils.PathService(options);
12
+ return {
13
+ plugins: [[require.resolve("./plugins/replace-source"), {
14
+ srcAbs: pathService.getSrcRootAbs(),
15
+ disableBuiltInRoute: options.disableBuiltInRoute
16
+ }], [require.resolve("./plugins/external-wrap"), {
17
+ pageRootAbs: pathService.getPageRootAbs(),
18
+ externals: options.externals
19
+ }], [require.resolve("./plugins/enhance-reducer"), {
20
+ pageRootAbs: pathService.getPageRootAbs(),
21
+ reducerName: options.reducerName
22
+ }]]
23
+ };
24
+ });
25
+ exports.default = _default;
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_helperPluginUtils","require","_utils","_default","declare","api","options","assertVersion","pathService","PathService","plugins","resolve","srcAbs","getSrcRootAbs","disableBuiltInRoute","pageRootAbs","getPageRootAbs","externals","reducerName","exports","default"],"sources":["../../index.ts"],"sourcesContent":["import { declare } from '@babel/helper-plugin-utils';\nimport { PathService, Options } from '../utils';\n\nexport default declare((api, options: Options) => {\n api.assertVersion(7);\n\n const pathService = new PathService(options);\n\n return {\n plugins: [\n [\n require.resolve('./plugins/replace-source'),\n {\n srcAbs: pathService.getSrcRootAbs(),\n disableBuiltInRoute: options.disableBuiltInRoute,\n },\n ],\n [\n require.resolve('./plugins/external-wrap'),\n {\n pageRootAbs: pathService.getPageRootAbs(),\n externals: options.externals,\n },\n ],\n [\n require.resolve('./plugins/enhance-reducer'),\n {\n pageRootAbs: pathService.getPageRootAbs(),\n reducerName: options.reducerName,\n },\n ],\n ],\n };\n});\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAAgD,IAAAE,QAAA,GAEjC,IAAAC,0BAAO,EAAC,CAACC,GAAG,EAAEC,OAAgB,KAAK;EAChDD,GAAG,CAACE,aAAa,CAAC,CAAC,CAAC;EAEpB,MAAMC,WAAW,GAAG,IAAIC,kBAAW,CAACH,OAAO,CAAC;EAE5C,OAAO;IACLI,OAAO,EAAE,CACP,CACET,OAAO,CAACU,OAAO,4BAA4B,EAC3C;MACEC,MAAM,EAAEJ,WAAW,CAACK,aAAa,EAAE;MACnCC,mBAAmB,EAAER,OAAO,CAACQ;IAC/B,CAAC,CACF,EACD,CACEb,OAAO,CAACU,OAAO,2BAA2B,EAC1C;MACEI,WAAW,EAAEP,WAAW,CAACQ,cAAc,EAAE;MACzCC,SAAS,EAAEX,OAAO,CAACW;IACrB,CAAC,CACF,EACD,CACEhB,OAAO,CAACU,OAAO,6BAA6B,EAC5C;MACEI,WAAW,EAAEP,WAAW,CAACQ,cAAc,EAAE;MACzCE,WAAW,EAAEZ,OAAO,CAACY;IACvB,CAAC,CACF;EAEL,CAAC;AACH,CAAC,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAjB,QAAA"}
@@ -0,0 +1,3 @@
1
+ declare const _default: any;
2
+ export default _default;
3
+ //# sourceMappingURL=enhance-reducer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enhance-reducer.d.ts","sourceRoot":"","sources":["../../../src/babel/plugins/enhance-reducer.ts"],"names":[],"mappings":";AAWA,wBAwDG"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _helperPluginUtils = require("@babel/helper-plugin-utils");
8
+ var _nodePath = _interopRequireDefault(require("node:path"));
9
+ var _fsExtra = _interopRequireDefault(require("fs-extra"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ var _default = (0, _helperPluginUtils.declare)((api, options) => {
12
+ const {
13
+ assertVersion,
14
+ types
15
+ } = api;
16
+ assertVersion(7);
17
+ const isMainRegex = new RegExp(`^${options.reducerName}.(j|t)s$`);
18
+ return {
19
+ name: 'babel-plugin-enhance-reducer',
20
+ visitor: {
21
+ ExportDefaultDeclaration: (babelPath, ops) => {
22
+ if (!new RegExp(`${options.pageRootAbs}\/.*${options.reducerName}\.(j|t)s`).test(ops.filename)) {
23
+ return;
24
+ }
25
+ const filename = _nodePath.default.basename(ops.filename);
26
+ function getMeJson(dir) {
27
+ if (_fsExtra.default.existsSync(_nodePath.default.join(dir, 'me.json'))) {
28
+ return dir;
29
+ }
30
+ return getMeJson(_nodePath.default.dirname(dir));
31
+ }
32
+ const baseDir = getMeJson(_nodePath.default.dirname(ops.filename));
33
+ if (!baseDir) {
34
+ return;
35
+ }
36
+ const meJSON = JSON.parse(_fsExtra.default.readFileSync(_nodePath.default.join(baseDir, 'me.json'), 'utf8'));
37
+ if (!meJSON.mobx) {
38
+ return;
39
+ }
40
+ let namespace = baseDir.replace(`${options.pageRootAbs}/`, '');
41
+ const isChild = !isMainRegex.test(filename);
42
+ if (isChild) {
43
+ namespace += `&&${filename.replace(new RegExp(`(.*)\.reducer\.(j|t)s`), '$1')}`;
44
+ }
45
+ const declaration = babelPath.get('declaration');
46
+ if (declaration.isObjectExpression() || declaration.isIdentifier()) {
47
+ const program = babelPath.findParent(x => x.isProgram());
48
+ if (program.isProgram()) {
49
+ const uid = program.scope.generateUidIdentifier('storeHoc');
50
+ const importMobxAdapter = types.importDeclaration([types.importDefaultSpecifier(uid)], isChild ? types.stringLiteral('rrc-loader-helper/lib/store') : types.stringLiteral('rrc-loader-helper/lib/mobx-adapter'));
51
+ program.unshiftContainer('body', importMobxAdapter);
52
+ const expression = types.callExpression(uid, [declaration.node, types.stringLiteral(namespace)]);
53
+ declaration.replaceWith(expression);
54
+ } else {
55
+ throw babelPath.buildCodeFrameError('语法解析错误,没有成功的探寻到 Program');
56
+ }
57
+ }
58
+ }
59
+ }
60
+ };
61
+ });
62
+ exports.default = _default;
63
+ //# sourceMappingURL=enhance-reducer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enhance-reducer.js","names":["_helperPluginUtils","require","_nodePath","_interopRequireDefault","_fsExtra","obj","__esModule","default","_default","declare","api","options","assertVersion","types","isMainRegex","RegExp","reducerName","name","visitor","ExportDefaultDeclaration","babelPath","ops","pageRootAbs","test","filename","path","basename","getMeJson","dir","fse","existsSync","join","dirname","baseDir","meJSON","JSON","parse","readFileSync","mobx","namespace","replace","isChild","declaration","get","isObjectExpression","isIdentifier","program","findParent","x","isProgram","uid","scope","generateUidIdentifier","importMobxAdapter","importDeclaration","importDefaultSpecifier","stringLiteral","unshiftContainer","expression","callExpression","node","replaceWith","buildCodeFrameError","exports"],"sources":["../../../enhance-reducer.ts"],"sourcesContent":["import type * as __babel__core from '@babel/core';\nimport { declare } from '@babel/helper-plugin-utils';\nimport path from 'node:path';\nimport fse from 'fs-extra';\nimport type { MeJSON } from '../../utils/types';\n\ninterface Options {\n pageRootAbs: string;\n reducerName: string;\n}\n\nexport default declare<Options>((api, options) => {\n const { assertVersion, types } = api;\n assertVersion(7);\n const isMainRegex = new RegExp(`^${options.reducerName}.(j|t)s$`);\n return {\n name: 'babel-plugin-enhance-reducer',\n visitor: {\n ExportDefaultDeclaration: (babelPath, ops) => {\n if (!new RegExp(`${options.pageRootAbs}\\/.*${options.reducerName}\\.(j|t)s`).test(ops.filename)) {\n return;\n }\n const filename = path.basename(ops.filename);\n\n function getMeJson(dir: string) {\n if (fse.existsSync(path.join(dir, 'me.json'))) {\n return dir;\n }\n return getMeJson(path.dirname(dir));\n }\n\n const baseDir = getMeJson(path.dirname(ops.filename));\n\n if (!baseDir) {\n return;\n }\n const meJSON: MeJSON = JSON.parse(fse.readFileSync(path.join(baseDir, 'me.json'), 'utf8'));\n\n if (!meJSON.mobx) {\n return;\n }\n\n let namespace = baseDir.replace(`${options.pageRootAbs}/`, '');\n const isChild = !isMainRegex.test(filename);\n\n if (isChild) {\n namespace += `&&${filename.replace(new RegExp(`(.*)\\.reducer\\.(j|t)s`), '$1')}`;\n }\n const declaration = babelPath.get('declaration');\n if (declaration.isObjectExpression() || declaration.isIdentifier()) {\n const program = babelPath.findParent((x) => x.isProgram());\n if (program.isProgram()) {\n const uid = program.scope.generateUidIdentifier('storeHoc');\n const importMobxAdapter = types.importDeclaration(\n [types.importDefaultSpecifier(uid)],\n isChild ? types.stringLiteral('rrc-loader-helper/lib/store') : types.stringLiteral('rrc-loader-helper/lib/mobx-adapter'),\n );\n program.unshiftContainer('body', importMobxAdapter);\n const expression = types.callExpression(uid, [declaration.node, types.stringLiteral(namespace)]);\n declaration.replaceWith(expression);\n } else {\n throw babelPath.buildCodeFrameError('语法解析错误,没有成功的探寻到 Program');\n }\n }\n },\n },\n };\n});\n"],"mappings":";;;;;;AACA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,QAAA,GAAAD,sBAAA,CAAAF,OAAA;AAA2B,SAAAE,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,IAAAG,QAAA,GAQZ,IAAAC,0BAAO,EAAU,CAACC,GAAG,EAAEC,OAAO,KAAK;EAChD,MAAM;IAAEC,aAAa;IAAEC;EAAM,CAAC,GAAGH,GAAG;EACpCE,aAAa,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@
1
+ {"version":3,"file":"external-wrap.d.ts","sourceRoot":"","sources":["../../../src/babel/plugins/external-wrap.ts"],"names":[],"mappings":";AASA,wBAkDG"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _helperPluginUtils = require("@babel/helper-plugin-utils");
8
+ var _path = _interopRequireDefault(require("path"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ var _default = (0, _helperPluginUtils.declare)((api, options) => {
11
+ const {
12
+ assertVersion,
13
+ types
14
+ } = api;
15
+ assertVersion(7);
16
+ return {
17
+ name: 'babel-plugin-external-wrap',
18
+ visitor: {
19
+ Program: {
20
+ enter: (nodePath, ops) => {
21
+ const externalsAbs = options.externals?.map?.(x => _path.default.join(options.pageRootAbs, x, 'view')) ?? [];
22
+ const isExternalView = externalsAbs.some(x => ops.filename.startsWith(x));
23
+ if (isExternalView) {
24
+ nodePath.scope.setData('isExternalView', true);
25
+ nodePath.pushContainer('body', [types.importDeclaration([types.importDefaultSpecifier(types.identifier('PvWrapExternalPage'))], types.stringLiteral('rrc-loader-helper/lib/page/external-page'))]);
26
+ }
27
+ }
28
+ },
29
+ ExportDefaultDeclaration: (nodePath, ops) => {
30
+ if (nodePath.scope.getData('isExternalView')) {
31
+ const pageName = _path.default.dirname(_path.default.relative(options.pageRootAbs, ops.filename));
32
+ const declarationPath = nodePath.get('declaration');
33
+ if (types.isCallExpression(declarationPath.node) || types.isIdentifier(declarationPath.node)) {
34
+ const call = types.callExpression(types.identifier('PvWrapExternalPage'), [declarationPath.node, types.stringLiteral(pageName)]);
35
+ nodePath.get('declaration').replaceWith(call);
36
+ }
37
+ }
38
+ }
39
+ }
40
+ };
41
+ });
42
+ exports.default = _default;
43
+ //# sourceMappingURL=external-wrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"external-wrap.js","names":["_helperPluginUtils","require","_path","_interopRequireDefault","obj","__esModule","default","_default","declare","api","options","assertVersion","types","name","visitor","Program","enter","nodePath","ops","externalsAbs","externals","map","x","path","join","pageRootAbs","isExternalView","some","filename","startsWith","scope","setData","pushContainer","importDeclaration","importDefaultSpecifier","identifier","stringLiteral","ExportDefaultDeclaration","getData","pageName","dirname","relative","declarationPath","get","isCallExpression","node","isIdentifier","call","callExpression","replaceWith","exports"],"sources":["../../../external-wrap.ts"],"sourcesContent":["import type * as __babel__core from '@babel/core';\nimport { declare } from '@babel/helper-plugin-utils';\nimport path from 'path';\n\ninterface Options {\n externals: string[];\n pageRootAbs: string;\n}\n\nexport default declare<Options>((api, options) => {\n const { assertVersion, types } = api;\n assertVersion(7);\n return {\n name: 'babel-plugin-external-wrap',\n visitor: {\n Program: {\n enter: (nodePath, ops) => {\n const externalsAbs =\n options.externals?.map?.((x) =>\n path.join(options.pageRootAbs, x, 'view'),\n ) ?? [];\n const isExternalView = externalsAbs.some((x) =>\n ops.filename.startsWith(x),\n );\n if (isExternalView) {\n nodePath.scope.setData('isExternalView', true);\n nodePath.pushContainer('body', [\n types.importDeclaration(\n [\n types.importDefaultSpecifier(\n types.identifier('PvWrapExternalPage'),\n ),\n ],\n types.stringLiteral('rrc-loader-helper/lib/page/external-page'),\n ),\n ]);\n }\n },\n },\n ExportDefaultDeclaration: (nodePath, ops) => {\n if (nodePath.scope.getData('isExternalView')) {\n const pageName = path.dirname(\n path.relative(options.pageRootAbs, ops.filename),\n );\n const declarationPath = nodePath.get('declaration');\n if (\n types.isCallExpression(declarationPath.node) ||\n types.isIdentifier(declarationPath.node)\n ) {\n const call = types.callExpression(\n types.identifier('PvWrapExternalPage'),\n [declarationPath.node, types.stringLiteral(pageName)],\n );\n nodePath.get('declaration').replaceWith(call);\n }\n }\n },\n },\n };\n});\n"],"mappings":";;;;;;AACA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAwB,SAAAE,uBAAAC,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AAC/B,OAAO,CAACe,WAAW,EAAEP,GAAG,CAACU,QAAQ,CAAC,CACjD;UACD,MAAMc,eAAe,GAAGzB,QAAQ,CAAC0B,GAAG,CAAC,aAAa,CAAC;UACnD,IACE/B,KAAK,CAACgC,gBAAgB,CAACF,eAAe,CAACG,IAAI,CAAC,IAC5CjC,KAAK,CAACkC,YAAY,CAACJ,eAAe,CAACG,IAAI,CAAC,EACxC;YACA,MAAME,IAAI,GAAGnC,KAAK,CAACoC,cAAc,CAC/BpC,KAAK,CAACuB,UAAU,CAAC,oBAAoB,CAAC,EACtC,CAACO,eAAe,CAACG,IAAI,EAAEjC,KAAK,CAACwB,aAAa,CAACG,QAAQ,CAAC,CAAC,CACtD;YACDtB,QAAQ,CAAC0B,GAAG,CAAC,aAAa,CAAC,CAACM,WAAW,CAACF,IAAI,CAAC;UAC/C;QACF;MACF;IACF;EACF,CAAC;AACH,CAAC,CAAC;AAAAG,OAAA,CAAA5C,OAAA,GAAAC,QAAA"}
@@ -0,0 +1,3 @@
1
+ declare const _default: any;
2
+ export default _default;
3
+ //# sourceMappingURL=replace-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replace-source.d.ts","sourceRoot":"","sources":["../../../src/babel/plugins/replace-source.ts"],"names":[],"mappings":";AAQA,wBA8GG"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _helperPluginUtils = require("@babel/helper-plugin-utils");
8
+ var _default = (0, _helperPluginUtils.declare)((api, options) => {
9
+ const {
10
+ assertVersion,
11
+ types
12
+ } = api;
13
+ assertVersion(7);
14
+ return {
15
+ name: 'babel-plugin-replace-source',
16
+ visitor: {
17
+ ImportDeclaration(nodePath, ops) {
18
+ const fromPath = nodePath.get('source');
19
+ const fromValue = fromPath.node.value;
20
+ const isSource = ops.filename.startsWith(options.srcAbs);
21
+ if (fromValue.startsWith('react-redux') && isSource) {
22
+ nodePath.set('source', types.stringLiteral(`rrc-loader-helper/lib/reducers/${fromValue}`));
23
+ } else if (fromValue.startsWith('react-router-dom') && !options.disableBuiltInRoute && isSource) {
24
+ nodePath.set('source', types.stringLiteral('rrc-loader-helper/router'));
25
+ } else if (fromValue.startsWith('redux-saga') && isSource) {
26
+ nodePath.set('source', types.stringLiteral(`rrc-loader-helper/lib/sagas/${fromValue}`));
27
+ }
28
+ },
29
+ Identifier: (nodePath, ops) => {
30
+ const program = nodePath.findParent(x => x.isProgram());
31
+ if (!program?.isProgram()) {
32
+ return;
33
+ }
34
+ if (nodePath.node.name === '__ROOT_REDUCER__') {
35
+ const reducersIdentifier = nodePath.scope.generateUidIdentifier('reducers');
36
+ program.unshiftContainer('body', [types.importDeclaration([types.importDefaultSpecifier(reducersIdentifier)], types.stringLiteral('@@/lessCoding/reducers'))]);
37
+ nodePath.replaceWith(reducersIdentifier);
38
+ } else if (nodePath.node.name === '__ROOT_SAGA__') {
39
+ const rootSaga = nodePath.scope.generateUidIdentifier('sagas');
40
+ program.unshiftContainer('body', [types.importDeclaration([types.importDefaultSpecifier(rootSaga)], types.stringLiteral('@@/lessCoding/sagas'))]);
41
+ nodePath.replaceWith(rootSaga);
42
+ } else if (nodePath.node.name === '__ROOT_ROUTE__') {
43
+ // FUCK
44
+ program.unshiftContainer('body', [types.importDeclaration([types.importSpecifier(types.identifier('setReducers'), types.identifier('setReducers'))], types.stringLiteral('rrc-loader-helper/lib/imp')), types.expressionStatement(types.callExpression(types.identifier('setReducers'), [types.identifier('reducers')]))]);
45
+ const routers = nodePath.scope.generateUidIdentifier('routers');
46
+ program.unshiftContainer('body', [types.importDeclaration([types.importDefaultSpecifier(routers)], types.stringLiteral('@@/lessCoding/routers'))]);
47
+ nodePath.replaceWith(types.callExpression(types.memberExpression(types.callExpression(routers, [types.identifier('reducers')]), types.identifier('map')), [types.arrowFunctionExpression([types.identifier('x')], types.blockStatement([types.returnStatement(types.jsxElement(types.jsxOpeningElement(types.jsxIdentifier('Route'), [types.jsxSpreadAttribute(types.identifier('x'))]), null, [], true))]))]));
48
+ }
49
+ }
50
+ }
51
+ };
52
+ });
53
+ exports.default = _default;
54
+ //# sourceMappingURL=replace-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replace-source.js","names":["_helperPluginUtils","require","_default","declare","api","options","assertVersion","types","name","visitor","ImportDeclaration","nodePath","ops","fromPath","get","fromValue","node","value","isSource","filename","startsWith","srcAbs","set","stringLiteral","disableBuiltInRoute","Identifier","program","findParent","x","isProgram","reducersIdentifier","scope","generateUidIdentifier","unshiftContainer","importDeclaration","importDefaultSpecifier","replaceWith","rootSaga","importSpecifier","identifier","expressionStatement","callExpression","routers","memberExpression","arrowFunctionExpression","blockStatement","returnStatement","jsxElement","jsxOpeningElement","jsxIdentifier","jsxSpreadAttribute","exports","default"],"sources":["../../../replace-source.ts"],"sourcesContent":["import type * as __babel__core from '@babel/core';\nimport { declare } from '@babel/helper-plugin-utils';\n\ninterface Options {\n srcAbs: string;\n disableBuiltInRoute: boolean;\n}\n\nexport default declare<Options>((api, options) => {\n const { assertVersion, types } = api;\n assertVersion(7);\n return {\n name: 'babel-plugin-replace-source',\n visitor: {\n ImportDeclaration(nodePath, ops) {\n const fromPath = nodePath.get('source');\n const fromValue = fromPath.node.value;\n const isSource = ops.filename.startsWith(options.srcAbs);\n if (fromValue.startsWith('react-redux') && isSource) {\n nodePath.set(\n 'source',\n types.stringLiteral(`rrc-loader-helper/lib/reducers/${fromValue}`),\n );\n } else if (\n fromValue.startsWith('react-router-dom') &&\n !options.disableBuiltInRoute &&\n isSource\n ) {\n nodePath.set(\n 'source',\n types.stringLiteral('rrc-loader-helper/router'),\n );\n } else if (fromValue.startsWith('redux-saga') && isSource) {\n nodePath.set(\n 'source',\n types.stringLiteral(`rrc-loader-helper/lib/sagas/${fromValue}`),\n );\n }\n },\n Identifier: (nodePath, ops) => {\n const program = nodePath.findParent((x) => x.isProgram());\n if (!program?.isProgram()) {\n return;\n }\n if (nodePath.node.name === '__ROOT_REDUCER__') {\n const reducersIdentifier =\n nodePath.scope.generateUidIdentifier('reducers');\n program.unshiftContainer('body', [\n types.importDeclaration(\n [types.importDefaultSpecifier(reducersIdentifier)],\n types.stringLiteral('@@/lessCoding/reducers'),\n ),\n ]);\n nodePath.replaceWith(reducersIdentifier);\n } else if (nodePath.node.name === '__ROOT_SAGA__') {\n const rootSaga = nodePath.scope.generateUidIdentifier('sagas');\n program.unshiftContainer('body', [\n types.importDeclaration(\n [types.importDefaultSpecifier(rootSaga)],\n types.stringLiteral('@@/lessCoding/sagas'),\n ),\n ]);\n nodePath.replaceWith(rootSaga);\n } else if (nodePath.node.name === '__ROOT_ROUTE__') {\n // FUCK\n program.unshiftContainer('body', [\n types.importDeclaration(\n [\n types.importSpecifier(\n types.identifier('setReducers'),\n types.identifier('setReducers'),\n ),\n ],\n types.stringLiteral('rrc-loader-helper/lib/imp'),\n ),\n types.expressionStatement(\n types.callExpression(types.identifier('setReducers'), [\n types.identifier('reducers'),\n ]),\n ),\n ]);\n\n const routers = nodePath.scope.generateUidIdentifier('routers');\n program.unshiftContainer('body', [\n types.importDeclaration(\n [types.importDefaultSpecifier(routers)],\n types.stringLiteral('@@/lessCoding/routers'),\n ),\n ]);\n nodePath.replaceWith(\n types.callExpression(\n types.memberExpression(\n types.callExpression(routers, [types.identifier('reducers')]),\n types.identifier('map'),\n ),\n [\n types.arrowFunctionExpression(\n [types.identifier('x')],\n types.blockStatement([\n types.returnStatement(\n types.jsxElement(\n types.jsxOpeningElement(types.jsxIdentifier('Route'), [\n types.jsxSpreadAttribute(types.identifier('x')),\n ]),\n null,\n [],\n true,\n ),\n ),\n ]),\n ),\n ],\n ),\n );\n }\n },\n },\n };\n});\n"],"mappings":";;;;;;AACA,IAAAA,kBAAA,GAAAC,OAAA;AAAqD,IAAAC,QAAA,GAOtC,IAAAC,0BAAO,EAAU,CAACC,GAAG,EAAEC,OAAO,KAAK;EAChD,MAAM;IAAEC,aAAa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AAK,CAACgC,UAAU,CAAC,UAAU,CAAC,CAC7B,CAAC,CACH,CACF,CAAC;UAEF,MAAMG,OAAO,GAAG/B,QAAQ,CAACoB,KAAK,CAACC,qBAAqB,CAAC,SAAS,CAAC;UAC/DN,OAAO,CAACO,gBAAgB,CAAC,MAAM,EAAE,CAC/B1B,KAAK,CAAC2B,iBAAiB,CACrB,CAAC3B,KAAK,CAAC4B,sBAAsB,CAACO,OAAO,CAAC,CAAC,EACvCnC,KAAK,CAACgB,aAAa,CAAC,uBAAuB,CAAC,CAC7C,CACF,CAAC;UACFZ,QAAQ,CAACyB,WAAW,CAClB7B,KAAK,CAACkC,cAAc,CAClBlC,KAAK,CAACoC,gBAAgB,CACpBpC,KAAK,CAACkC,cAAc,CAACC,OAAO,EAAE,CAACnC,KAAK,CAACgC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,EAC7DhC,KAAK,CAACgC,UAAU,CAAC,KAAK,CAAC,CACxB,EACD,CACEhC,KAAK,CAACqC,uBAAuB,CAC3B,CAACrC,KAAK,CAACgC,UAAU,CAAC,GAAG,CAAC,CAAC,EACvBhC,KAAK,CAACsC,cAAc,CAAC,CACnBtC,KAAK,CAACuC,eAAe,CACnBvC,KAAK,CAACwC,UAAU,CACdxC,KAAK,CAACyC,iBAAiB,CAACzC,KAAK,CAAC0C,aAAa,CAAC,OAAO,CAAC,EAAE,CACpD1C,KAAK,CAAC2C,kBAAkB,CAAC3C,KAAK,CAACgC,UAAU,CAAC,GAAG,CAAC,CAAC,CAChD,CAAC,EACF,IAAI,EACJ,EAAE,EACF,IAAI,CACL,CACF,CACF,CAAC,CACH,CACF,CACF,CACF;QACH;MACF;IACF;EACF,CAAC;AACH,CAAC,CAAC;AAAAY,OAAA,CAAAC,OAAA,GAAAlD,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAI/D,OAAO,EAAyB,OAAO,EAAe,MAAM,SAAS,CAAC;AAOtE,MAAM,CAAC,OAAO,OAAO,sBAAuB,YAAW,qBAAqB;IAC1E,OAAO,EAAE,OAAO,CAAC;gBACL,OAAO,EAAE,OAAO;IAI5B,KAAK,CAAC,QAAQ,EAAE,QAAQ;IA8LxB,YAAY,CAAC,QAAQ,EAAE,QAAQ;CAYhC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAI/D,OAAO,EAAyB,OAAO,EAAe,MAAM,SAAS,CAAC;AAOtE,MAAM,CAAC,OAAO,OAAO,sBAAuB,YAAW,qBAAqB;IAC1E,OAAO,EAAE,OAAO,CAAC;gBACL,OAAO,EAAE,OAAO;IAI5B,KAAK,CAAC,QAAQ,EAAE,QAAQ;IAoOxB,YAAY,CAAC,QAAQ,EAAE,QAAQ;CAYhC"}
package/lib/index.js CHANGED
@@ -20,6 +20,8 @@ class LcdRouterWebpackPlugin {
20
20
  }
21
21
  apply(compiler) {
22
22
  this.mergeOptions(compiler);
23
+
24
+ // 处理 lcd 中的路由体系
23
25
  compiler.hooks.afterPlugins.tap('LcdRouterWebpackPlugin', compiler => {
24
26
  const options = this.options;
25
27
  const pathService = new _utils.PathService(options);
@@ -183,6 +185,25 @@ class LcdRouterWebpackPlugin {
183
185
  watcher.on('error', fn);
184
186
  }
185
187
  });
188
+
189
+ // lcd 中包含一些语法转换处理
190
+ compiler.hooks.environment.tap('lcd-preset', () => {
191
+ compiler.options.module.rules.push({
192
+ test: /\.(js|ts)x?$/,
193
+ exclude: /node_modules/,
194
+ use: [{
195
+ loader: require.resolve('babel-loader'),
196
+ options: {
197
+ presets: [[require.resolve("./babel/index"), this.options]],
198
+ babelrc: false,
199
+ // 需要支持语法解析, 但不需要做转换
200
+ parserOpts: {
201
+ plugins: ['jsx', 'typescript', 'asyncDoExpressions', 'decimal', 'decorators-legacy', 'decoratorAutoAccessors', 'destructuringPrivate', 'doExpressions', 'exportDefaultFrom', 'functionBind', 'functionSent', 'importAssertions', 'moduleBlocks', 'partialApplication', 'throwExpressions']
202
+ }
203
+ }
204
+ }]
205
+ });
206
+ });
186
207
  }
187
208
  mergeOptions(compiler) {
188
209
  const defaultOptions = {
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_globby","_interopRequireDefault","require","_chokidar","_deepmerge","_utils","_ReducersGenerator","_SagasGenerator","_RoutersGenerator","_nodePath","obj","__esModule","default","LcdRouterWebpackPlugin","options","constructor","apply","compiler","mergeOptions","hooks","afterPlugins","tap","pathService","PathService","resolver","Resolver","fileService","FileService","reducersGenerator","ReducersGenerator","sagasGenerator","SagasGenerator","routersGenerator","RoutersGenerator","isDev","mode","process","env","NODE_ENV","writeCode","writeCodeToFile","getReducersCacheFileAbs","getSagasCacheFileAbs","getRoutersCacheFileAbs","resolveFile","filepath","absFilePath","getCurrentFileAbs","currentDir","path","dirname","absCurrentDir","chunkCode","meJSON","readJSONSync","reducerPath","getReducerFile","push","e","mobx","Error","viewPath","getViewFile","theme","hash","sagaPath","getSagaFile","errorComponent","errorCompPath","getErrorComFile","themePath","getThemeJSCacheFileAbs","writeThemeFile","meJSONPath","getMeJSONCacheFileAbs","writeMeJSONFile","isExternal","externals","some","x","hasChildStore","globby","sync","reducerName","cwd","length","set","namespace","page","exact","RegExp","index","test","_key","replace","list","getPageRootAbs","console","warn","sortedList","map","sort","a","b","startsWith","localeCompare","dir","forEach","watcher","chokidar","watch","ignoreInitial","fn","on","defaultOptions","context","enablePreFetch","pageDir","disableBuiltInRoute","deepmerge","exports"],"sources":["../index.ts"],"sourcesContent":["import type { Compiler, WebpackPluginInstance } from 'webpack';\nimport globby from 'globby';\nimport chokidar from 'chokidar';\nimport deepmerge from 'deepmerge';\nimport { PathService, Resolver, Options, FileService } from './utils';\nimport { ReducersGenerator } from './ReducersGenerator';\nimport { SagasGenerator } from './SagasGenerator';\nimport { RoutersGenerator } from './RoutersGenerator';\n\nimport path from 'node:path';\n\nexport default class LcdRouterWebpackPlugin implements WebpackPluginInstance {\n options: Options;\n constructor(options: Options) {\n this.options = options;\n }\n\n apply(compiler: Compiler) {\n this.mergeOptions(compiler);\n\n compiler.hooks.afterPlugins.tap('LcdRouterWebpackPlugin', (compiler) => {\n const options = this.options;\n\n const pathService = new PathService(options);\n const resolver = new Resolver(compiler, options);\n const fileService = new FileService(pathService);\n\n const reducersGenerator = new ReducersGenerator();\n const sagasGenerator = new SagasGenerator();\n const routersGenerator = new RoutersGenerator(options, pathService);\n\n function isDev(compiler) {\n if (compiler.options.mode === 'production' || process.env.NODE_ENV === 'production') return false;\n return true;\n }\n\n function writeCode() {\n reducersGenerator.writeCodeToFile(pathService.getReducersCacheFileAbs());\n sagasGenerator.writeCodeToFile(pathService.getSagasCacheFileAbs());\n routersGenerator.writeCodeToFile(pathService.getRoutersCacheFileAbs());\n }\n\n function resolveFile(filepath: string) {\n const absFilePath = pathService.getCurrentFileAbs(filepath);\n const currentDir = path.dirname(filepath);\n const absCurrentDir = path.dirname(absFilePath);\n\n const chunkCode = [] as string[];\n const meJSON = fileService.readJSONSync(absFilePath);\n try {\n const reducerPath = resolver.getReducerFile(absCurrentDir);\n chunkCode.push(`export { default as reducer } from '${reducerPath}';`);\n } catch (e) {\n // feat: reducers 可以不存在, 方便结合reactive 和 ak,默认创建一个reducers\n if (meJSON.mobx) {\n /**\n * mobx 模式下, 需要垫一个被 mobx-adapter 包裹的 reducer 函数\n * 如果存在reducer文件,是默认会被 babel-plugin-enhance-reducer 处理的\n *\n * import storeHoc from 'rrc-loader-helper/lib/mobx-adapter';\n * export const reducer = storeHoc({\n * state: {},\n * }, 'report/other-table')\n *\n * 不太方便去垫一个 reducer 函数,reducer 的路径计算比较复杂, 所以直接报错\n * 同时,从逻辑上讲,如果开启了 mobx,那么必须要有 reducer 文件\n */\n throw Error(`开启 mobx 后,reducer 文件必须存在 ${absFilePath}`);\n }\n chunkCode.push(`export function reducer(){ return {} }`);\n }\n\n const viewPath = resolver.getViewFile(absCurrentDir);\n chunkCode.push(`export { default as view } from '${viewPath}';`);\n\n if (meJSON.theme && !options.theme?.hash) {\n throw Error(`开启页面级主题之前,请优先开启全局主题 ${absFilePath}`);\n }\n\n if (!meJSON.mobx) {\n try {\n const sagaPath = resolver.getSagaFile(absCurrentDir);\n chunkCode.push(`export { default as saga } from '${sagaPath}';`);\n } catch (e) {\n // feat: saga 也可以不存在, 方便结合reactive 和 ak,默认创建一个reducers\n chunkCode.push(`export function* saga(){ return {} }`);\n }\n }\n\n if (meJSON.errorComponent) {\n const errorCompPath = resolver.getErrorComFile(absCurrentDir, meJSON.errorComponent);\n chunkCode.push(`export { default as ErrorComponent } from '${errorCompPath}';`);\n }\n\n if (options.theme?.hash) {\n const themePath = pathService.getThemeJSCacheFileAbs(options.theme?.hash);\n chunkCode.push(`export * from '${themePath}';`);\n }\n\n if (meJSON.theme) {\n fileService.writeThemeFile(meJSON.theme, 'toGlobalTheme');\n const themePath = pathService.getThemeJSCacheFileAbs(meJSON.theme);\n chunkCode.push(`export * from '${themePath}';`);\n }\n\n const meJSONPath = pathService.getMeJSONCacheFileAbs(filepath);\n\n fileService.writeMeJSONFile(meJSONPath, chunkCode);\n\n const isExternal = options.externals?.some?.((x) => x === path.dirname(filepath)) ?? false;\n\n // 处理是否存在多store的场景\n const hasChildStore = globby.sync(`**/*.${options.reducerName}.{t,j}s`, { cwd: absCurrentDir }).length > 0;\n if (hasChildStore && (meJSON.sync || isExternal)) {\n throw Error(`如果开启了Sync模式或当前页面存在于LCD的external中,那么则不支持多Store功能,${absCurrentDir}`);\n }\n\n /** reducers.js */\n reducersGenerator.set(filepath, {\n meJSON,\n isExternal,\n namespace: currentDir,\n meJSONPath: meJSONPath,\n });\n\n /** saga.js */\n sagasGenerator.set(currentDir, {\n meJSON,\n isExternal,\n namespace: currentDir,\n meJSONPath: meJSONPath,\n });\n\n /** router */\n routersGenerator.set(currentDir, {\n meJSON,\n isExternal,\n page: currentDir,\n path: currentDir,\n exact: false,\n meJSONPath: meJSONPath,\n });\n\n /** 处理 /list 的路由 */\n if (new RegExp(`\\/${options.index}$`).test(absCurrentDir)) {\n const _key = absCurrentDir.replace(new RegExp(`\\/${options.index}$`), '');\n routersGenerator.set(_key, {\n meJSON,\n isExternal,\n page: absCurrentDir,\n path: _key,\n exact: true,\n meJSONPath: meJSONPath,\n });\n }\n }\n\n if (options.theme?.hash) {\n fileService.writeThemeFile(options.theme.hash, 'toGlobalTheme');\n }\n\n const list = globby.sync('**/me.json', {\n cwd: pathService.getPageRootAbs(),\n });\n\n if (list.length === 0) {\n console.warn('没有找到me.json文件');\n }\n\n /**\n * glob 的排序 是包含文件名 me.json 的完整路径,存在问题\n * 比如 会将 /xx/ss/me.json 排到 /xx/ss/zz/me.json 前面\n * glob 的 noSort option 会将 文件夹排到前面, 因此需要手动排序, 并且统一成 globby, 速度更快\n */\n const sortedList = list\n .map((filepath) => filepath?.replace(/me.json$/, ''))\n .sort((a, b) => {\n if (a?.startsWith(b)) return -1;\n return a.localeCompare(b, 'en');\n })\n .map((dir) => `${dir}me.json`);\n\n sortedList.forEach((filepath) => {\n resolveFile(filepath);\n });\n\n writeCode();\n\n if (isDev(compiler)) {\n const watcher = chokidar.watch('**/me.json', {\n cwd: pathService.getPageRootAbs(),\n ignoreInitial: true,\n });\n const fn = async (filepath) => {\n await resolveFile(filepath);\n writeCode();\n };\n watcher.on('add', fn);\n watcher.on('addDir', fn);\n watcher.on('change', fn);\n watcher.on('unlink', fn);\n watcher.on('unlinkDir', fn);\n watcher.on('error', fn);\n }\n });\n }\n\n mergeOptions(compiler: Compiler) {\n const defaultOptions = {\n context: compiler.context,\n enablePreFetch: false,\n index: 'list',\n externals: [],\n pageDir: 'component',\n reducerName: 'reducers',\n disableBuiltInRoute: false,\n };\n this.options = deepm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ACF,MAAMC,EAAE,GAAG,MAAOnE,QAAQ,IAAK;UAC7B,MAAMD,WAAW,CAACC,QAAQ,CAAC;UAC3BN,SAAS,EAAE;QACb,CAAC;QACDqE,OAAO,CAACK,EAAE,CAAC,KAAK,EAAED,EAAE,CAAC;QACrBJ,OAAO,CAACK,EAAE,CAAC,QAAQ,EAAED,EAAE,CAAC;QACxBJ,OAAO,CAACK,EAAE,CAAC,QAAQ,EAAED,EAAE,CAAC;QACxBJ,OAAO,CAACK,EAAE,CAAC,QAAQ,EAAED,EAAE,CAAC;QACxBJ,OAAO,CAACK,EAAE,CAAC,WAAW,EAAED,EAAE,CAAC;QAC3BJ,OAAO,CAACK,EAAE,CAAC,OAAO,EAAED,EAAE,CAAC;MACzB;IACF,CAAC,CAAC;EACJ;EAEA9F,YAAYA,CAACD,QAAkB,EAAE;IAC/B,MAAMiG,cAAc,GAAG;MACrBC,OAAO,EAAElG,QAAQ,CAACkG,OAAO;MACzBC,cAAc,EAAE,KAAK;MACrBzB,KAAK,EAAE,MAAM;MACbd,SAAS,EAAE,EAAE;MACbwC,OAAO,EAAE,WAAW;MACpBlC,WAAW,EAAE,UAAU;MACvBmC,mBAAmB,EAAE;IACvB,CAAC;IACD,IAAI,CAACxG,OAAO,GAAG,IAAAyG,kBAAS,EAACL,cAAc,EAAE,IAAI,CAACpG,OAAO,CAAC;EACxD;AACF;AAAC0G,OAAA,CAAA5G,OAAA,GAAAC,sBAAA"}
1
+ {"version":3,"file":"index.js","names":["_globby","_interopRequireDefault","require","_chokidar","_deepmerge","_utils","_ReducersGenerator","_SagasGenerator","_RoutersGenerator","_nodePath","obj","__esModule","default","LcdRouterWebpackPlugin","options","constructor","apply","compiler","mergeOptions","hooks","afterPlugins","tap","pathService","PathService","resolver","Resolver","fileService","FileService","reducersGenerator","ReducersGenerator","sagasGenerator","SagasGenerator","routersGenerator","RoutersGenerator","isDev","mode","process","env","NODE_ENV","writeCode","writeCodeToFile","getReducersCacheFileAbs","getSagasCacheFileAbs","getRoutersCacheFileAbs","resolveFile","filepath","absFilePath","getCurrentFileAbs","currentDir","path","dirname","absCurrentDir","chunkCode","meJSON","readJSONSync","reducerPath","getReducerFile","push","e","mobx","Error","viewPath","getViewFile","theme","hash","sagaPath","getSagaFile","errorComponent","errorCompPath","getErrorComFile","themePath","getThemeJSCacheFileAbs","writeThemeFile","meJSONPath","getMeJSONCacheFileAbs","writeMeJSONFile","isExternal","externals","some","x","hasChildStore","globby","sync","reducerName","cwd","length","set","namespace","page","exact","RegExp","index","test","_key","replace","list","getPageRootAbs","console","warn","sortedList","map","sort","a","b","startsWith","localeCompare","dir","forEach","watcher","chokidar","watch","ignoreInitial","fn","on","environment","module","rules","exclude","use","loader","resolve","presets","babelrc","parserOpts","plugins","defaultOptions","context","enablePreFetch","pageDir","disableBuiltInRoute","deepmerge","exports"],"sources":["../index.ts"],"sourcesContent":["import type { Compiler, WebpackPluginInstance } from 'webpack';\nimport globby from 'globby';\nimport chokidar from 'chokidar';\nimport deepmerge from 'deepmerge';\nimport { PathService, Resolver, Options, FileService } from './utils';\nimport { ReducersGenerator } from './ReducersGenerator';\nimport { SagasGenerator } from './SagasGenerator';\nimport { RoutersGenerator } from './RoutersGenerator';\n\nimport path from 'node:path';\n\nexport default class LcdRouterWebpackPlugin implements WebpackPluginInstance {\n options: Options;\n constructor(options: Options) {\n this.options = options;\n }\n\n apply(compiler: Compiler) {\n this.mergeOptions(compiler);\n\n // 处理 lcd 中的路由体系\n compiler.hooks.afterPlugins.tap('LcdRouterWebpackPlugin', (compiler) => {\n const options = this.options;\n\n const pathService = new PathService(options);\n const resolver = new Resolver(compiler, options);\n const fileService = new FileService(pathService);\n\n const reducersGenerator = new ReducersGenerator();\n const sagasGenerator = new SagasGenerator();\n const routersGenerator = new RoutersGenerator(options, pathService);\n\n function isDev(compiler) {\n if (compiler.options.mode === 'production' || process.env.NODE_ENV === 'production') return false;\n return true;\n }\n\n function writeCode() {\n reducersGenerator.writeCodeToFile(pathService.getReducersCacheFileAbs());\n sagasGenerator.writeCodeToFile(pathService.getSagasCacheFileAbs());\n routersGenerator.writeCodeToFile(pathService.getRoutersCacheFileAbs());\n }\n\n function resolveFile(filepath: string) {\n const absFilePath = pathService.getCurrentFileAbs(filepath);\n const currentDir = path.dirname(filepath);\n const absCurrentDir = path.dirname(absFilePath);\n\n const chunkCode = [] as string[];\n const meJSON = fileService.readJSONSync(absFilePath);\n try {\n const reducerPath = resolver.getReducerFile(absCurrentDir);\n chunkCode.push(`export { default as reducer } from '${reducerPath}';`);\n } catch (e) {\n // feat: reducers 可以不存在, 方便结合reactive 和 ak,默认创建一个reducers\n if (meJSON.mobx) {\n /**\n * mobx 模式下, 需要垫一个被 mobx-adapter 包裹的 reducer 函数\n * 如果存在reducer文件,是默认会被 babel-plugin-enhance-reducer 处理的\n *\n * import storeHoc from 'rrc-loader-helper/lib/mobx-adapter';\n * export const reducer = storeHoc({\n * state: {},\n * }, 'report/other-table')\n *\n * 不太方便去垫一个 reducer 函数,reducer 的路径计算比较复杂, 所以直接报错\n * 同时,从逻辑上讲,如果开启了 mobx,那么必须要有 reducer 文件\n */\n throw Error(`开启 mobx 后,reducer 文件必须存在 ${absFilePath}`);\n }\n chunkCode.push(`export function reducer(){ return {} }`);\n }\n\n const viewPath = resolver.getViewFile(absCurrentDir);\n chunkCode.push(`export { default as view } from '${viewPath}';`);\n\n if (meJSON.theme && !options.theme?.hash) {\n throw Error(`开启页面级主题之前,请优先开启全局主题 ${absFilePath}`);\n }\n\n if (!meJSON.mobx) {\n try {\n const sagaPath = resolver.getSagaFile(absCurrentDir);\n chunkCode.push(`export { default as saga } from '${sagaPath}';`);\n } catch (e) {\n // feat: saga 也可以不存在, 方便结合reactive 和 ak,默认创建一个reducers\n chunkCode.push(`export function* saga(){ return {} }`);\n }\n }\n\n if (meJSON.errorComponent) {\n const errorCompPath = resolver.getErrorComFile(absCurrentDir, meJSON.errorComponent);\n chunkCode.push(`export { default as ErrorComponent } from '${errorCompPath}';`);\n }\n\n if (options.theme?.hash) {\n const themePath = pathService.getThemeJSCacheFileAbs(options.theme?.hash);\n chunkCode.push(`export * from '${themePath}';`);\n }\n\n if (meJSON.theme) {\n fileService.writeThemeFile(meJSON.theme, 'toGlobalTheme');\n const themePath = pathService.getThemeJSCacheFileAbs(meJSON.theme);\n chunkCode.push(`export * from '${themePath}';`);\n }\n\n const meJSONPath = pathService.getMeJSONCacheFileAbs(filepath);\n\n fileService.writeMeJSONFile(meJSONPath, chunkCode);\n\n const isExternal = options.externals?.some?.((x) => x === path.dirname(filepath)) ?? false;\n\n // 处理是否存在多store的场景\n const hasChildStore = globby.sync(`**/*.${options.reducerName}.{t,j}s`, { cwd: absCurrentDir }).length > 0;\n if (hasChildStore && (meJSON.sync || isExternal)) {\n throw Error(`如果开启了Sync模式或当前页面存在于LCD的external中,那么则不支持多Store功能,${absCurrentDir}`);\n }\n\n /** reducers.js */\n reducersGenerator.set(filepath, {\n meJSON,\n isExternal,\n namespace: currentDir,\n meJSONPath: meJSONPath,\n });\n\n /** saga.js */\n sagasGenerator.set(currentDir, {\n meJSON,\n isExternal,\n namespace: currentDir,\n meJSONPath: meJSONPath,\n });\n\n /** router */\n routersGenerator.set(currentDir, {\n meJSON,\n isExternal,\n page: currentDir,\n path: currentDir,\n exact: false,\n meJSONPath: meJSONPath,\n });\n\n /** 处理 /list 的路由 */\n if (new RegExp(`\\/${options.index}$`).test(absCurrentDir)) {\n const _key = absCurrentDir.replace(new RegExp(`\\/${options.index}$`), '');\n routersGenerator.set(_key, {\n meJSON,\n isExternal,\n page: absCurrentDir,\n path: _key,\n exact: true,\n meJSONPath: meJSONPath,\n });\n }\n }\n\n if (options.theme?.hash) {\n fileService.writeThemeFile(options.theme.hash, 'toGlobalTheme');\n }\n\n const list = globby.sync('**/me.json', {\n cwd: pathService.getPageRootAbs(),\n });\n\n if (list.length === 0) {\n console.warn('没有找到me.json文件');\n }\n\n /**\n * glob 的排序 是包含文件名 me.json 的完整路径,存在问题\n * 比如 会将 /xx/ss/me.json 排到 /xx/ss/zz/me.json 前面\n * glob 的 noSort option 会将 文件夹排到前面, 因此需要手动排序, 并且统一成 globby, 速度更快\n */\n const sortedList = list\n .map((filepath) => filepath?.replace(/me.json$/, ''))\n .sort((a, b) => {\n if (a?.startsWith(b)) return -1;\n return a.localeCompare(b, 'en');\n })\n .map((dir) => `${dir}me.json`);\n\n sortedList.forEach((filepath) => {\n resolveFile(filepath);\n });\n\n writeCode();\n\n if (isDev(compiler)) {\n const watcher = chokidar.watch('**/me.json', {\n cwd: pathService.getPageRootAbs(),\n ignoreInitial: true,\n });\n const fn = async (filepath) => {\n await resolveFile(filepath);\n writeCode();\n };\n watcher.on('add', fn);\n watcher.on('addDir', fn);\n watcher.on('change', fn);\n watcher.on('unlink', fn);\n watcher.on('unlinkDir', fn);\n watcher.on('error', fn);\n }\n });\n\n // lcd 中包含一些语法转换处理\n compiler.hooks.environment.tap('lcd-preset', () => {\n compiler.options.module.rules.push({\n test: /\\.(js|ts)x?$/,\n exclude: /node_modules/,\n use: [\n {\n loader: require.resolve('babel-loader'),\n options: {\n presets: [[require.resolve('./babel/index'), this.options]],\n babelrc: false,\n // 需要支持语法解析, 但不需要做转换\n parserOpts: {\n plugins: [\n 'jsx',\n 'typescript',\n 'asyncDoExpressions',\n 'decimal',\n 'decorators-legacy',\n 'decoratorAutoAccessors',\n 'destructuringPrivate',\n 'doExpressions',\n 'exportDefaultFrom',\n 'functionBind',\n 'functionSent',\n 'importAssertions',\n 'moduleBlocks',\n 'partialApplication',\n 'throwExpressions',\n ],\n },\n },\n },\n ],\n });\n });\n }\n\n mergeOptions(compiler: Compiler) {\n const defaultOptions = {\n context: compiler.context,\n enablePreFetch: false,\n index: 'list',\n externals: [],\n pageDir: 'component',\n reducerName: 'reducers',\n disableBuiltInRoute: false,\n };\n this.options = deepmerge(defaultOptions, this.options);\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAA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MACzBC,cAAc,EAAE,KAAK;MACrBpC,KAAK,EAAE,MAAM;MACbd,SAAS,EAAE,EAAE;MACbmD,OAAO,EAAE,WAAW;MACpB7C,WAAW,EAAE,UAAU;MACvB8C,mBAAmB,EAAE;IACvB,CAAC;IACD,IAAI,CAACnH,OAAO,GAAG,IAAAoH,kBAAS,EAACL,cAAc,EAAE,IAAI,CAAC/G,OAAO,CAAC;EACxD;AACF;AAACqH,OAAA,CAAAvH,OAAA,GAAAC,sBAAA"}
@@ -1,4 +1,4 @@
1
- import type { Options } from '../utils';
1
+ import type { Options } from '.';
2
2
  export declare const dir = "lessCoding";
3
3
  export declare const themes = "themes";
4
4
  export declare const LcdTempDir = ".lego";
@@ -1 +1 @@
1
- {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/utils/paths.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,eAAO,MAAM,GAAG,eAAe,CAAC;AAEhC,eAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,eAAO,MAAM,UAAU,UAAU,CAAC;AAElC;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,EAAE,OAAO,CAAC;IAEjB,OAAO,EAAE,MAAM,CAAC;gBAEJ,OAAO,KAAA;IAKnB;;;;;SAKK;IACL,cAAc;IAId,aAAa;IAIb;;SAEK;IACL,iBAAiB,CAAC,gBAAgB,EAAE,MAAM;IAI1C,kBAAkB;IAClB,gBAAgB,CAAC,gBAAgB,EAAE,MAAM;IAIzC,wBAAwB;IACxB,uBAAuB;IAIvB,qBAAqB;IACrB,oBAAoB;IAIpB,uBAAuB;IACvB,sBAAsB;IAItB,oBAAoB;IACpB,sBAAsB,CAAC,IAAI,EAAE,MAAM;IAInC,yBAAyB;IACzB,qBAAqB,CAAC,gBAAgB,EAAE,MAAM;IAI9C,sBAAsB,CAAC,gBAAgB,EAAE,MAAM;CAGhD"}
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/utils/paths.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC;AAEjC,eAAO,MAAM,GAAG,eAAe,CAAC;AAEhC,eAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,eAAO,MAAM,UAAU,UAAU,CAAC;AAElC;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,EAAE,OAAO,CAAC;IAEjB,OAAO,EAAE,MAAM,CAAC;gBAEJ,OAAO,KAAA;IAKnB;;;;;SAKK;IACL,cAAc;IAId,aAAa;IAIb;;SAEK;IACL,iBAAiB,CAAC,gBAAgB,EAAE,MAAM;IAI1C,kBAAkB;IAClB,gBAAgB,CAAC,gBAAgB,EAAE,MAAM;IAIzC,wBAAwB;IACxB,uBAAuB;IAIvB,qBAAqB;IACrB,oBAAoB;IAIpB,uBAAuB;IACvB,sBAAsB;IAItB,oBAAoB;IACpB,sBAAsB,CAAC,IAAI,EAAE,MAAM;IAInC,yBAAyB;IACzB,qBAAqB,CAAC,gBAAgB,EAAE,MAAM;IAI9C,sBAAsB,CAAC,gBAAgB,EAAE,MAAM;CAGhD"}
@@ -1 +1 @@
1
- {"version":3,"file":"paths.js","names":["_path","_interopRequireDefault","require","obj","__esModule","default","dir","exports","themes","LcdTempDir","PathService","options","legoAbs","constructor","path","join","context","getPageRootAbs","pageDir","getSrcRootAbs","getCurrentFileAbs","relativeFilePath","getCurrentDirAbs","dirname","getReducersCacheFileAbs","getSagasCacheFileAbs","getRoutersCacheFileAbs","getThemeJSCacheFileAbs","hash","getMeJSONCacheFileAbs","getMeJsonCacheFileName","replace"],"sources":["../../paths.ts"],"sourcesContent":["import path from 'path';\nimport type { Options } from '../utils';\n\nexport const dir = 'lessCoding';\n\nexport const themes = 'themes';\n\nexport const LcdTempDir = '.lego';\n\n/**\n * 路径处理服务\n */\nexport class PathService {\n options: Options;\n\n legoAbs: string;\n\n constructor(options) {\n this.options = options;\n this.legoAbs = path.join(this.options.context!, 'src', LcdTempDir);\n }\n\n /**\n * 页面根目录绝对路径\n * 通常都是\n * - src\n * - components\n * */\n getPageRootAbs() {\n return path.join(this.options.context!, 'src', this.options.pageDir);\n }\n\n getSrcRootAbs() {\n return path.join(this.options.context!, 'src');\n }\n\n /**\n * 当前文件的绝对路径\n * */\n getCurrentFileAbs(relativeFilePath: string) {\n return path.join(this.getPageRootAbs(), relativeFilePath);\n }\n\n /** 当前文件的绝对目录路径 */\n getCurrentDirAbs(relativeFilePath: string) {\n return path.join(this.getPageRootAbs(), path.dirname(relativeFilePath));\n }\n\n /** 生成的 reducers 文件路径 */\n getReducersCacheFileAbs() {\n return path.join(this.legoAbs, dir, 'reducers.js');\n }\n\n /** 生成的 sagas 文件路径 */\n getSagasCacheFileAbs() {\n return path.join(this.legoAbs, dir, 'sagas.js');\n }\n\n /** 生成的 routers 文件路径 */\n getRoutersCacheFileAbs() {\n return path.join(this.legoAbs, dir, 'routers.js');\n }\n\n /** 主题文件cache 的路径 */\n getThemeJSCacheFileAbs(hash: string) {\n return path.join(this.legoAbs, dir, themes, `${hash}.js`);\n }\n\n /** 获取 mejson 编译后的文件路径 */\n getMeJSONCacheFileAbs(relativeFilePath: string) {\n return path.join(this.legoAbs, dir, 'me-json', this.getMeJsonCacheFileName(relativeFilePath));\n }\n\n getMeJsonCacheFileName(relativeFilePath: string) {\n return relativeFilePath.replace(/(.*)\\/me\\.json$/, '$1.js').replace(/\\//g, '-_-');\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAwB,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAGjB,MAAMG,GAAG,GAAG,YAAY;AAACC,OAAA,CAAAD,GAAA,GAAAA,GAAA;AAEzB,MAAME,MAAM,GAAG,QAAQ;AAACD,OAAA,CAAAC,MAAA,GAAAA,MAAA;AAExB,MAAM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OAAOZ,aAAI,CAACC,IAAI,CAAC,IAAI,CAACH,OAAO,EAAEN,GAAG,EAAE,YAAY,CAAC;EACnD;;EAEA;EACAqB,sBAAsBA,CAACC,IAAY,EAAE;IACnC,OAAOd,aAAI,CAACC,IAAI,CAAC,IAAI,CAACH,OAAO,EAAEN,GAAG,EAAEE,MAAM,EAAG,GAAEoB,IAAK,KAAI,CAAC;EAC3D;;EAEA;EACAC,qBAAqBA,CAACR,gBAAwB,EAAE;IAC9C,OAAOP,aAAI,CAACC,IAAI,CAAC,IAAI,CAACH,OAAO,EAAEN,GAAG,EAAE,SAAS,EAAE,IAAI,CAACwB,sBAAsB,CAACT,gBAAgB,CAAC,CAAC;EAC/F;EAEAS,sBAAsBA,CAACT,gBAAwB,EAAE;IAC/C,OAAOA,gBAAgB,CAACU,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAACA,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;EACnF;AACF;AAACxB,OAAA,CAAAG,WAAA,GAAAA,WAAA"}
1
+ {"version":3,"file":"paths.js","names":["_path","_interopRequireDefault","require","obj","__esModule","default","dir","exports","themes","LcdTempDir","PathService","options","legoAbs","constructor","path","join","context","getPageRootAbs","pageDir","getSrcRootAbs","getCurrentFileAbs","relativeFilePath","getCurrentDirAbs","dirname","getReducersCacheFileAbs","getSagasCacheFileAbs","getRoutersCacheFileAbs","getThemeJSCacheFileAbs","hash","getMeJSONCacheFileAbs","getMeJsonCacheFileName","replace"],"sources":["../../paths.ts"],"sourcesContent":["import path from 'path';\nimport type { Options } from '.';\n\nexport const dir = 'lessCoding';\n\nexport const themes = 'themes';\n\nexport const LcdTempDir = '.lego';\n\n/**\n * 路径处理服务\n */\nexport class PathService {\n options: Options;\n\n legoAbs: string;\n\n constructor(options) {\n this.options = options;\n this.legoAbs = path.join(this.options.context!, 'src', LcdTempDir);\n }\n\n /**\n * 页面根目录绝对路径\n * 通常都是\n * - src\n * - components\n * */\n getPageRootAbs() {\n return path.join(this.options.context!, 'src', this.options.pageDir);\n }\n\n getSrcRootAbs() {\n return path.join(this.options.context!, 'src');\n }\n\n /**\n * 当前文件的绝对路径\n * */\n getCurrentFileAbs(relativeFilePath: string) {\n return path.join(this.getPageRootAbs(), relativeFilePath);\n }\n\n /** 当前文件的绝对目录路径 */\n getCurrentDirAbs(relativeFilePath: string) {\n return path.join(this.getPageRootAbs(), path.dirname(relativeFilePath));\n }\n\n /** 生成的 reducers 文件路径 */\n getReducersCacheFileAbs() {\n return path.join(this.legoAbs, dir, 'reducers.js');\n }\n\n /** 生成的 sagas 文件路径 */\n getSagasCacheFileAbs() {\n return path.join(this.legoAbs, dir, 'sagas.js');\n }\n\n /** 生成的 routers 文件路径 */\n getRoutersCacheFileAbs() {\n return path.join(this.legoAbs, dir, 'routers.js');\n }\n\n /** 主题文件cache 的路径 */\n getThemeJSCacheFileAbs(hash: string) {\n return path.join(this.legoAbs, dir, themes, `${hash}.js`);\n }\n\n /** 获取 mejson 编译后的文件路径 */\n getMeJSONCacheFileAbs(relativeFilePath: string) {\n return path.join(this.legoAbs, dir, 'me-json', this.getMeJsonCacheFileName(relativeFilePath));\n }\n\n getMeJsonCacheFileName(relativeFilePath: string) {\n return relativeFilePath.replace(/(.*)\\/me\\.json$/, '$1.js').replace(/\\//g, '-_-');\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAwB,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAGjB,MAAMG,GAAG,GAAG,YAAY;AAACC,OAAA,CAAAD,GAAA,GAAAA,GAAA;AAEzB,MAAME,MAAM,GAAG,QAAQ;AAACD,OAAA,CAAAC,MAAA,GAAAA,MAAA;AAExB,MAAMC,UAAU,GAAG,OAAO;;AAEjC;AACA;AACA;AAFAF,OAAA,CAAAE,UAAA,GAAAA,UAAA;AAGO,MAAMC,WA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;EACAqB,sBAAsBA,CAACC,IAAY,EAAE;IACnC,OAAOd,aAAI,CAACC,IAAI,CAAC,IAAI,CAACH,OAAO,EAAEN,GAAG,EAAEE,MAAM,EAAG,GAAEoB,IAAK,KAAI,CAAC;EAC3D;;EAEA;EACAC,qBAAqBA,CAACR,gBAAwB,EAAE;IAC9C,OAAOP,aAAI,CAACC,IAAI,CAAC,IAAI,CAACH,OAAO,EAAEN,GAAG,EAAE,SAAS,EAAE,IAAI,CAACwB,sBAAsB,CAACT,gBAAgB,CAAC,CAAC;EAC/F;EAEAS,sBAAsBA,CAACT,gBAAwB,EAAE;IAC/C,OAAOA,gBAAgB,CAACU,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAACA,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;EACnF;AACF;AAACxB,OAAA,CAAAG,WAAA,GAAAA,WAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lcd-router-webpack-plugin",
3
- "version": "9.0.0-alpha.7",
3
+ "version": "9.0.0-alpha.9",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -22,7 +22,8 @@
22
22
  "@babel/core": "^7.23.0"
23
23
  },
24
24
  "peerDependencies": {
25
- "webpack": ">=5"
25
+ "webpack": ">=5",
26
+ "babel-loader": ">=9"
26
27
  },
27
28
  "scripts": {
28
29
  "build": "lecp",