@tarojs/webpack5-prebundle 3.5.0-alpha.16
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.
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/h5.d.ts +23 -0
- package/dist/h5.js +193 -0
- package/dist/h5.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +87 -0
- package/dist/index.js.map +1 -0
- package/dist/mini.d.ts +9 -0
- package/dist/mini.js +244 -0
- package/dist/mini.js.map +1 -0
- package/dist/prebundle/bundle.d.ts +25 -0
- package/dist/prebundle/bundle.js +188 -0
- package/dist/prebundle/bundle.js.map +1 -0
- package/dist/prebundle/index.d.ts +48 -0
- package/dist/prebundle/index.js +186 -0
- package/dist/prebundle/index.js.map +1 -0
- package/dist/prebundle/scanImports.d.ts +10 -0
- package/dist/prebundle/scanImports.js +192 -0
- package/dist/prebundle/scanImports.js.map +1 -0
- package/dist/utils/constant.d.ts +14 -0
- package/dist/utils/constant.js +66 -0
- package/dist/utils/constant.js.map +1 -0
- package/dist/utils/index.d.ts +34 -0
- package/dist/utils/index.js +182 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/path.d.ts +3 -0
- package/dist/utils/path.js +12 -0
- package/dist/utils/path.js.map +1 -0
- package/dist/utils/webpack.d.ts +10 -0
- package/dist/utils/webpack.js +39 -0
- package/dist/utils/webpack.js.map +1 -0
- package/dist/webpack/TaroContainerEntryModule.d.ts +12 -0
- package/dist/webpack/TaroContainerEntryModule.js +78 -0
- package/dist/webpack/TaroContainerEntryModule.js.map +1 -0
- package/dist/webpack/TaroContainerEntryModuleFactory.d.ts +6 -0
- package/dist/webpack/TaroContainerEntryModuleFactory.js +17 -0
- package/dist/webpack/TaroContainerEntryModuleFactory.js.map +1 -0
- package/dist/webpack/TaroContainerPlugin.d.ts +25 -0
- package/dist/webpack/TaroContainerPlugin.js +77 -0
- package/dist/webpack/TaroContainerPlugin.js.map +1 -0
- package/dist/webpack/TaroContainerReferencePlugin.d.ts +26 -0
- package/dist/webpack/TaroContainerReferencePlugin.js +187 -0
- package/dist/webpack/TaroContainerReferencePlugin.js.map +1 -0
- package/dist/webpack/TaroModuleFederationPlugin.d.ts +21 -0
- package/dist/webpack/TaroModuleFederationPlugin.js +75 -0
- package/dist/webpack/TaroModuleFederationPlugin.js.map +1 -0
- package/dist/webpack/TaroRemoteRuntimeModule.d.ts +14 -0
- package/dist/webpack/TaroRemoteRuntimeModule.js +117 -0
- package/dist/webpack/TaroRemoteRuntimeModule.js.map +1 -0
- package/dist/webpack/index.d.ts +0 -0
- package/dist/webpack/index.js +1 -0
- package/dist/webpack/index.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.scanImports = void 0;
|
|
16
|
+
const esbuild_1 = __importDefault(require("esbuild"));
|
|
17
|
+
const fs_1 = __importDefault(require("fs"));
|
|
18
|
+
const path_1 = __importDefault(require("path"));
|
|
19
|
+
const utils_1 = require("../utils");
|
|
20
|
+
const constant_1 = require("../utils/constant");
|
|
21
|
+
function scanImports({ appPath, entries, include = [], exclude = [], customEsbuildConfig = {} }, deps = new Map()) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const scanImportsPlugin = getScanImportsPlugin(deps, include, exclude);
|
|
24
|
+
const customPlugins = customEsbuildConfig.plugins || [];
|
|
25
|
+
yield Promise.all(entries.map((entry) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
try {
|
|
27
|
+
yield esbuild_1.default.build(Object.assign(Object.assign({}, customEsbuildConfig), { absWorkingDir: appPath, bundle: true, entryPoints: [entry], mainFields: ['main:h5', 'browser', 'module', 'jsnext:main', 'main'], format: 'esm', loader: constant_1.defaultEsbuildLoader, write: false, plugins: [
|
|
28
|
+
scanImportsPlugin,
|
|
29
|
+
...customPlugins
|
|
30
|
+
] }));
|
|
31
|
+
}
|
|
32
|
+
catch (e) { }
|
|
33
|
+
})));
|
|
34
|
+
// 有一些 Webpack loaders 添加的依赖没有办法提前分析出来
|
|
35
|
+
// 可以把它们写进 includes,然后在这里 resolve 后加入到 deps
|
|
36
|
+
const resolve = (0, utils_1.getResolve)();
|
|
37
|
+
yield Promise.all(include.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
if ((0, utils_1.isExclude)(item, exclude))
|
|
39
|
+
return;
|
|
40
|
+
const resolvePath = yield resolve(appPath, item);
|
|
41
|
+
deps.set(item, resolvePath);
|
|
42
|
+
})));
|
|
43
|
+
return deps;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
exports.scanImports = scanImports;
|
|
47
|
+
/**
|
|
48
|
+
* 收集 node_modules 依赖
|
|
49
|
+
* Circumstances:
|
|
50
|
+
* 1. import 'xxx.scss', import '../xxx.png' => external
|
|
51
|
+
* 2. import 'xxx.vue', import '../xxx.vue'
|
|
52
|
+
* => collect script: { key: { loader, contents } }
|
|
53
|
+
* => virtual-mode compose of "export * from 'key';""
|
|
54
|
+
* => load virtual-mode and return { loader, contents }
|
|
55
|
+
* 3. import 'xxx', import 'xxx/yyy.ext', import '@xxx/alias'
|
|
56
|
+
* => resolve
|
|
57
|
+
* => path.includes(node_modules) && .js|.jsx|.ts|.tsx => collect + external
|
|
58
|
+
* => .vue => (2)
|
|
59
|
+
* => asserts => (1)
|
|
60
|
+
* => src => return
|
|
61
|
+
* 4. import '../xxx', import '../xxx.ext'
|
|
62
|
+
* => resolve
|
|
63
|
+
* => .vue => (2)
|
|
64
|
+
* => src => return
|
|
65
|
+
*/
|
|
66
|
+
function getScanImportsPlugin(deps, includes, excludes) {
|
|
67
|
+
const resolve = (0, utils_1.getResolve)();
|
|
68
|
+
// for storing vue <script> contents
|
|
69
|
+
const scripts = new Map();
|
|
70
|
+
return {
|
|
71
|
+
name: 'scanImports',
|
|
72
|
+
setup(build) {
|
|
73
|
+
// assets
|
|
74
|
+
build.onResolve(({ filter: constant_1.assetsRE }), utils_1.externalModule);
|
|
75
|
+
// .vue
|
|
76
|
+
build.onLoad({ filter: /\.vue$/, namespace: 'vue' }, ({ path }) => {
|
|
77
|
+
let raw = fs_1.default.readFileSync(path, 'utf-8');
|
|
78
|
+
raw = raw.replace(constant_1.commentRE, '<!---->');
|
|
79
|
+
const regex = constant_1.scriptRE;
|
|
80
|
+
regex.lastIndex = 0;
|
|
81
|
+
let js = '';
|
|
82
|
+
let scriptId = 0;
|
|
83
|
+
let match;
|
|
84
|
+
while ((match = regex.exec(raw))) {
|
|
85
|
+
const [, openTag, content] = match;
|
|
86
|
+
const langMatch = openTag.match(constant_1.langRE);
|
|
87
|
+
const lang = langMatch && (langMatch[1] || langMatch[2] || langMatch[3]);
|
|
88
|
+
let loader = 'js';
|
|
89
|
+
if (lang === 'ts' || lang === 'tsx' || lang === 'jsx') {
|
|
90
|
+
loader = lang;
|
|
91
|
+
}
|
|
92
|
+
if (content.trim()) {
|
|
93
|
+
// append imports in TS to prevent esbuild from removing them
|
|
94
|
+
// since they may be used in the template
|
|
95
|
+
const contents = content +
|
|
96
|
+
(loader.startsWith('ts') ? extractImportPaths(content) : '');
|
|
97
|
+
const key = `${path}?id=${scriptId++}`;
|
|
98
|
+
scripts.set(key, {
|
|
99
|
+
loader,
|
|
100
|
+
contents
|
|
101
|
+
});
|
|
102
|
+
const virtualModulePath = JSON.stringify(constant_1.virtualModulePrefix + key);
|
|
103
|
+
js += `export * from ${virtualModulePath}\n`;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// "export * from" syntax will not re'export "default", so we patch one.
|
|
107
|
+
if (!js.includes('export default')) {
|
|
108
|
+
js += 'export default {}';
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
loader: 'js',
|
|
112
|
+
contents: js
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
build.onResolve(({ filter: constant_1.virtualModuleRE }), ({ path }) => {
|
|
116
|
+
return {
|
|
117
|
+
path: path.replace(constant_1.virtualModulePrefix, ''),
|
|
118
|
+
namespace: 'script'
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
build.onLoad(({ filter: /.*/, namespace: 'script' }), ({ path }) => {
|
|
122
|
+
return scripts.get(path);
|
|
123
|
+
});
|
|
124
|
+
// bare imports
|
|
125
|
+
build.onResolve({ filter: constant_1.moduleRE }, ({ path: id, importer }) => __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
if ((0, utils_1.isExclude)(id, excludes))
|
|
127
|
+
return (0, utils_1.externalModule)({ path: id });
|
|
128
|
+
if (deps.has(id))
|
|
129
|
+
return (0, utils_1.externalModule)({ path: id });
|
|
130
|
+
try {
|
|
131
|
+
const resolvedPath = yield resolve(path_1.default.dirname(importer), id);
|
|
132
|
+
if (resolvedPath.includes('node_modules') || includes.includes(id)) {
|
|
133
|
+
if ((0, utils_1.isOptimizeIncluded)(resolvedPath)) {
|
|
134
|
+
deps.set(id, resolvedPath);
|
|
135
|
+
}
|
|
136
|
+
return (0, utils_1.externalModule)({ path: id });
|
|
137
|
+
}
|
|
138
|
+
else if ((0, utils_1.isScanIncluded)(resolvedPath)) {
|
|
139
|
+
return {
|
|
140
|
+
path: resolvedPath,
|
|
141
|
+
namespace: 'vue'
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
else if (constant_1.assetsRE.test(resolvedPath)) {
|
|
145
|
+
(0, utils_1.externalModule)({ path: id });
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
return {
|
|
149
|
+
path: resolvedPath
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
154
|
+
return (0, utils_1.externalModule)({ path: id });
|
|
155
|
+
}
|
|
156
|
+
}));
|
|
157
|
+
// catch all
|
|
158
|
+
build.onResolve({ filter: /.*/ }, ({ path: id, importer }) => __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
const resolvedPath = yield resolve(path_1.default.dirname(importer), id);
|
|
160
|
+
const namespace = (0, utils_1.isScanIncluded)(resolvedPath) ? 'vue' : undefined;
|
|
161
|
+
return {
|
|
162
|
+
path: resolvedPath,
|
|
163
|
+
namespace
|
|
164
|
+
};
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* when using TS + (Vue + `<script setup>`) or Svelte, imports may seem
|
|
171
|
+
* unused to esbuild and dropped in the build output, which prevents
|
|
172
|
+
* esbuild from crawling further.
|
|
173
|
+
* the solution is to add `import 'x'` for every source to force
|
|
174
|
+
* esbuild to keep crawling due to potential side effects.
|
|
175
|
+
*/
|
|
176
|
+
function extractImportPaths(code) {
|
|
177
|
+
// empty singleline & multiline comments to avoid matching comments
|
|
178
|
+
code = code
|
|
179
|
+
.replace(constant_1.multilineCommentsRE, '/* */')
|
|
180
|
+
.replace(constant_1.singlelineCommentsRE, '');
|
|
181
|
+
let js = '';
|
|
182
|
+
let m;
|
|
183
|
+
while ((m = constant_1.importsRE.exec(code)) != null) {
|
|
184
|
+
// This is necessary to avoid infinite loops with zero-width matches
|
|
185
|
+
if (m.index === constant_1.importsRE.lastIndex) {
|
|
186
|
+
constant_1.importsRE.lastIndex++;
|
|
187
|
+
}
|
|
188
|
+
js += `\nimport ${m[1]}`;
|
|
189
|
+
}
|
|
190
|
+
return js;
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=scanImports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanImports.js","sourceRoot":"","sources":["../../src/prebundle/scanImports.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sDAAyC;AACzC,4CAAmB;AACnB,gDAAuB;AAEvB,oCAMiB;AACjB,gDAa0B;AAU1B,SAAsB,WAAW,CAAE,EACjC,OAAO,EACP,OAAO,EACP,OAAO,GAAG,EAAE,EACZ,OAAO,GAAG,EAAE,EACZ,mBAAmB,GAAG,EAAE,EACN,EACpB,OAAsB,IAAI,GAAG,EAAE;;QAE7B,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QACtE,MAAM,aAAa,GAAG,mBAAmB,CAAC,OAAO,IAAI,EAAE,CAAA;QAEvD,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAM,KAAK,EAAC,EAAE;YAC1C,IAAI;gBACF,MAAM,iBAAO,CAAC,KAAK,iCACd,mBAAmB,KACtB,aAAa,EAAE,OAAO,EACtB,MAAM,EAAE,IAAI,EACZ,WAAW,EAAE,CAAC,KAAK,CAAC,EACpB,UAAU,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,CAAC,EACnE,MAAM,EAAE,KAAK,EACb,MAAM,EAAE,+BAAoB,EAC5B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE;wBACP,iBAAiB;wBACjB,GAAG,aAAa;qBACjB,IACD,CAAA;aACH;YAAC,OAAO,CAAC,EAAE,GAAE;QAChB,CAAC,CAAA,CAAC,CAAC,CAAA;QAEH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OAAO,CAAC,8BAAmB,EAAE,OAAO,CAAC;SACrC,OAAO,CAAC,+BAAoB,EAAE,EAAE,CAAC,CAAA;IAEpC,IAAI,EAAE,GAAG,EAAE,CAAA;IACX,IAAI,CAAC,CAAA;IACL,OAAO,CAAC,CAAC,GAAG,oBAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,EAAE;QACzC,oEAAoE;QACpE,IAAI,CAAC,CAAC,KAAK,KAAK,oBAAS,CAAC,SAAS,EAAE;YACnC,oBAAS,CAAC,SAAS,EAAE,CAAA;SACtB;QACD,EAAE,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;KACzB;IACD,OAAO,EAAE,CAAA;AACX,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Loader } from 'esbuild';
|
|
2
|
+
export declare const virtualModulePrefix = "virtual-module:";
|
|
3
|
+
export declare const virtualModuleRE: RegExp;
|
|
4
|
+
export declare const assetsRE: RegExp;
|
|
5
|
+
export declare const commentRE: RegExp;
|
|
6
|
+
export declare const scriptRE: RegExp;
|
|
7
|
+
export declare const langRE: RegExp;
|
|
8
|
+
export declare const multilineCommentsRE: RegExp;
|
|
9
|
+
export declare const singlelineCommentsRE: RegExp;
|
|
10
|
+
export declare const importsRE: RegExp;
|
|
11
|
+
export declare const moduleRE: RegExp;
|
|
12
|
+
export declare type CollectedDeps = Map<string, string>;
|
|
13
|
+
export declare const MF_NAME = "taro_app_library";
|
|
14
|
+
export declare const defaultEsbuildLoader: Record<string, Loader>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultEsbuildLoader = exports.MF_NAME = exports.moduleRE = exports.importsRE = exports.singlelineCommentsRE = exports.multilineCommentsRE = exports.langRE = exports.scriptRE = exports.commentRE = exports.assetsRE = exports.virtualModuleRE = exports.virtualModulePrefix = void 0;
|
|
4
|
+
const KNOWN_ASSET_TYPES = [
|
|
5
|
+
// css
|
|
6
|
+
'css',
|
|
7
|
+
'less',
|
|
8
|
+
'sass',
|
|
9
|
+
'scss',
|
|
10
|
+
'styl',
|
|
11
|
+
'stylus',
|
|
12
|
+
'pcss',
|
|
13
|
+
'postcss',
|
|
14
|
+
// json
|
|
15
|
+
'json',
|
|
16
|
+
// images
|
|
17
|
+
'png',
|
|
18
|
+
'jpe?g',
|
|
19
|
+
'gif',
|
|
20
|
+
'svg',
|
|
21
|
+
'ico',
|
|
22
|
+
'webp',
|
|
23
|
+
'avif',
|
|
24
|
+
// media
|
|
25
|
+
'mp4',
|
|
26
|
+
'webm',
|
|
27
|
+
'ogg',
|
|
28
|
+
'mp3',
|
|
29
|
+
'wav',
|
|
30
|
+
'flac',
|
|
31
|
+
'aac',
|
|
32
|
+
// fonts
|
|
33
|
+
'woff2?',
|
|
34
|
+
'eot',
|
|
35
|
+
'ttf',
|
|
36
|
+
'otf',
|
|
37
|
+
// other
|
|
38
|
+
'wasm',
|
|
39
|
+
'webmanifest',
|
|
40
|
+
'pdf',
|
|
41
|
+
'txt'
|
|
42
|
+
];
|
|
43
|
+
exports.virtualModulePrefix = 'virtual-module:';
|
|
44
|
+
exports.virtualModuleRE = new RegExp(`^${exports.virtualModulePrefix}`);
|
|
45
|
+
exports.assetsRE = new RegExp(`\\.(${KNOWN_ASSET_TYPES.join('|')})$`);
|
|
46
|
+
exports.commentRE = /<!--(.|[\r\n])*?-->/;
|
|
47
|
+
exports.scriptRE = /(<script\b(?:\s[^>]*>|>))(.*?)<\/script>/gims;
|
|
48
|
+
exports.langRE = /\blang\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/im;
|
|
49
|
+
exports.multilineCommentsRE = /\/\*(.|[\r\n])*?\*\//gm;
|
|
50
|
+
exports.singlelineCommentsRE = /\/\/.*/g;
|
|
51
|
+
// A simple regex to detect import sources. This is only used on
|
|
52
|
+
// <script lang="ts"> blocks in vue (setup only) or svelte files, since
|
|
53
|
+
// seemingly unused imports are dropped by esbuild when transpiling TS which
|
|
54
|
+
// prevents it from crawling further.
|
|
55
|
+
// We can't use es-module-lexer because it can't handle TS, and don't want to
|
|
56
|
+
// use Acorn because it's slow. Luckily this doesn't have to be bullet proof
|
|
57
|
+
// since even missed imports can be caught at runtime, and false positives will
|
|
58
|
+
// simply be ignored.
|
|
59
|
+
exports.importsRE = /(?<!\/\/.*)(?<=^|;|\*\/)\s*import(?!\s+type)(?:[\w*{}\n\r\t, ]+from\s*)?\s*("[^"]+"|'[^']+')\s*(?=$|;|\/\/|\/\*)/gm;
|
|
60
|
+
exports.moduleRE = /^[^./\\][^:]/;
|
|
61
|
+
exports.MF_NAME = 'taro_app_library';
|
|
62
|
+
exports.defaultEsbuildLoader = {
|
|
63
|
+
'.js': 'jsx',
|
|
64
|
+
'.ts': 'tsx'
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../src/utils/constant.ts"],"names":[],"mappings":";;;AAEA,MAAM,iBAAiB,GAAG;IACxB,MAAM;IACN,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,QAAQ;IACR,MAAM;IACN,SAAS;IAET,OAAO;IACP,MAAM;IAEN,SAAS;IACT,KAAK;IACL,OAAO;IACP,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;IAEN,QAAQ;IACR,KAAK;IACL,MAAM;IACN,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,KAAK;IAEL,QAAQ;IACR,QAAQ;IACR,KAAK;IACL,KAAK;IACL,KAAK;IAEL,QAAQ;IACR,MAAM;IACN,aAAa;IACb,KAAK;IACL,KAAK;CACN,CAAA;AAEY,QAAA,mBAAmB,GAAG,iBAAiB,CAAA;AACvC,QAAA,eAAe,GAAG,IAAI,MAAM,CAAC,IAAI,2BAAmB,EAAE,CAAC,CAAA;AAEvD,QAAA,QAAQ,GAAG,IAAI,MAAM,CAAC,OAAO,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAE7D,QAAA,SAAS,GAAG,qBAAqB,CAAA;AACjC,QAAA,QAAQ,GAAG,8CAA8C,CAAA;AACzD,QAAA,MAAM,GAAG,oDAAoD,CAAA;AAC7D,QAAA,mBAAmB,GAAG,wBAAwB,CAAA;AAC9C,QAAA,oBAAoB,GAAG,SAAS,CAAA;AAE7C,gEAAgE;AAChE,uEAAuE;AACvE,4EAA4E;AAC5E,qCAAqC;AACrC,6EAA6E;AAC7E,4EAA4E;AAC5E,+EAA+E;AAC/E,qBAAqB;AACR,QAAA,SAAS,GACpB,oHAAoH,CAAA;AAEzG,QAAA,QAAQ,GAAG,cAAc,CAAA;AAIzB,QAAA,OAAO,GAAG,kBAAkB,CAAA;AAE5B,QAAA,oBAAoB,GAA2B;IAC1D,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,KAAK;CACb,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import Chain from 'webpack-chain';
|
|
2
|
+
import type { CollectedDeps } from './constant';
|
|
3
|
+
export interface Metadata {
|
|
4
|
+
bundleHash?: string;
|
|
5
|
+
mfHash?: string;
|
|
6
|
+
taroRuntimeBundlePath?: string;
|
|
7
|
+
runtimeRequirements?: Set<string>;
|
|
8
|
+
remoteAssets?: {
|
|
9
|
+
name: string;
|
|
10
|
+
}[];
|
|
11
|
+
}
|
|
12
|
+
export declare function createResolve(appPath: string, resolveOptions: any): void;
|
|
13
|
+
export declare function getResolve(): (importer: string, request: string) => Promise<string>;
|
|
14
|
+
export declare function externalModule({ path }: {
|
|
15
|
+
path: string;
|
|
16
|
+
}): {
|
|
17
|
+
path: string;
|
|
18
|
+
external: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare function flattenId(id: string): string;
|
|
21
|
+
export declare function getCacheDir(appPath: string, env?: string): string;
|
|
22
|
+
export declare function getDefines(chain: Chain): any;
|
|
23
|
+
export declare function isExclude(id: string, excludes: (string | RegExp)[]): boolean;
|
|
24
|
+
export declare function isOptimizeIncluded(path: string): boolean;
|
|
25
|
+
export declare function isScanIncluded(path: string): boolean;
|
|
26
|
+
export declare function getHash(content: string): string;
|
|
27
|
+
export declare function getBundleHash(appPath: string, deps: CollectedDeps, chain: Chain, cacheDir: string): Promise<string>;
|
|
28
|
+
export declare const sortDeps: (a: string | string[], b: string | string[]) => number;
|
|
29
|
+
export declare function formatDepsString(deps: CollectedDeps): string;
|
|
30
|
+
export declare function getMfHash(obj: Record<string, any>): string;
|
|
31
|
+
export declare function commitMeta(appPath: string, metadataPath: string, metadata: Metadata): Promise<void>;
|
|
32
|
+
export declare function getMeasure(isLogTiming?: boolean): (name: string, start: number) => void;
|
|
33
|
+
export * from './path';
|
|
34
|
+
export * from './webpack';
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.getMeasure = exports.commitMeta = exports.getMfHash = exports.formatDepsString = exports.sortDeps = exports.getBundleHash = exports.getHash = exports.isScanIncluded = exports.isOptimizeIncluded = exports.isExclude = exports.getDefines = exports.getCacheDir = exports.flattenId = exports.externalModule = exports.getResolve = exports.createResolve = void 0;
|
|
30
|
+
const helper_1 = require("@tarojs/helper");
|
|
31
|
+
const crypto_1 = require("crypto");
|
|
32
|
+
const enhanced_resolve_1 = __importDefault(require("enhanced-resolve"));
|
|
33
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
34
|
+
const path_1 = __importDefault(require("path"));
|
|
35
|
+
const perf_hooks_1 = require("perf_hooks");
|
|
36
|
+
let resolve;
|
|
37
|
+
function createResolve(appPath, resolveOptions) {
|
|
38
|
+
const defaultResolveOptions = {
|
|
39
|
+
conditionNames: ['require', 'import', 'module', 'webpack', 'development', 'browser'],
|
|
40
|
+
aliasFields: ['browser'],
|
|
41
|
+
cache: true,
|
|
42
|
+
mainFiles: ['index'],
|
|
43
|
+
exportsFields: ['exports'],
|
|
44
|
+
roots: appPath
|
|
45
|
+
};
|
|
46
|
+
const resolver = enhanced_resolve_1.default.create(Object.assign(Object.assign({}, defaultResolveOptions), resolveOptions));
|
|
47
|
+
resolve = function (importer, request) {
|
|
48
|
+
return new Promise((resolve, reject) => {
|
|
49
|
+
resolver({}, importer, request, {}, (err, resolvedPath) => {
|
|
50
|
+
if (err)
|
|
51
|
+
return reject(err);
|
|
52
|
+
resolve(resolvedPath);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
exports.createResolve = createResolve;
|
|
58
|
+
function getResolve() {
|
|
59
|
+
return resolve;
|
|
60
|
+
}
|
|
61
|
+
exports.getResolve = getResolve;
|
|
62
|
+
function externalModule({ path }) {
|
|
63
|
+
return {
|
|
64
|
+
path,
|
|
65
|
+
external: true
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
exports.externalModule = externalModule;
|
|
69
|
+
function flattenId(id) {
|
|
70
|
+
return id.replace(/(\s*>\s*)/g, '__').replace(/[/.:]/g, '_');
|
|
71
|
+
}
|
|
72
|
+
exports.flattenId = flattenId;
|
|
73
|
+
function getCacheDir(appPath, env = '') {
|
|
74
|
+
return path_1.default.resolve(appPath, './node_modules/.taro', env);
|
|
75
|
+
}
|
|
76
|
+
exports.getCacheDir = getCacheDir;
|
|
77
|
+
function getDefines(chain) {
|
|
78
|
+
let defines;
|
|
79
|
+
if (chain.plugins.has('definePlugin')) {
|
|
80
|
+
chain.plugin('definePlugin').tap(args => {
|
|
81
|
+
defines = args[0];
|
|
82
|
+
return args;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return defines;
|
|
86
|
+
}
|
|
87
|
+
exports.getDefines = getDefines;
|
|
88
|
+
function isExclude(id, excludes) {
|
|
89
|
+
return Boolean(excludes.find(item => {
|
|
90
|
+
const dollarTailRE = /\$$/;
|
|
91
|
+
if (item instanceof RegExp) {
|
|
92
|
+
return item.test(id);
|
|
93
|
+
}
|
|
94
|
+
else if (dollarTailRE.test(item)) {
|
|
95
|
+
// 全路径匹配
|
|
96
|
+
item = item.replace(dollarTailRE, '');
|
|
97
|
+
if (item === id)
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
if (item === id || id.startsWith(item + '/'))
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
exports.isExclude = isExclude;
|
|
107
|
+
function isOptimizeIncluded(path) {
|
|
108
|
+
return /\.[jt]sx?$/.test(path);
|
|
109
|
+
}
|
|
110
|
+
exports.isOptimizeIncluded = isOptimizeIncluded;
|
|
111
|
+
function isScanIncluded(path) {
|
|
112
|
+
return /\.vue/.test(path);
|
|
113
|
+
}
|
|
114
|
+
exports.isScanIncluded = isScanIncluded;
|
|
115
|
+
function getHash(content) {
|
|
116
|
+
return (0, crypto_1.createHash)('sha256').update(content).digest('hex').substring(0, 8);
|
|
117
|
+
}
|
|
118
|
+
exports.getHash = getHash;
|
|
119
|
+
function getBundleHash(appPath, deps, chain, cacheDir) {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
const defines = getDefines(chain);
|
|
122
|
+
const lockfiles = ['package-lock.json', 'yarn.lock', 'pnpm-lock.yaml'];
|
|
123
|
+
const lockfilesContents = yield Promise.all(lockfiles.map(item => {
|
|
124
|
+
return new Promise(resolve => {
|
|
125
|
+
fs_extra_1.default.readFile(path_1.default.join(appPath, item))
|
|
126
|
+
.then(content => resolve(content.toString()))
|
|
127
|
+
.catch(() => resolve(''));
|
|
128
|
+
});
|
|
129
|
+
}));
|
|
130
|
+
return getHash(formatDepsString(deps) +
|
|
131
|
+
lockfilesContents.join('\n') +
|
|
132
|
+
JSON.stringify(defines) +
|
|
133
|
+
cacheDir);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
exports.getBundleHash = getBundleHash;
|
|
137
|
+
const sortDeps = (a, b) => {
|
|
138
|
+
const x = typeof a === 'string' ? a : a[0];
|
|
139
|
+
const y = typeof b === 'string' ? b : b[0];
|
|
140
|
+
return x.localeCompare(y);
|
|
141
|
+
};
|
|
142
|
+
exports.sortDeps = sortDeps;
|
|
143
|
+
function formatDepsString(deps) {
|
|
144
|
+
const list = Array.from(deps.entries()).sort(exports.sortDeps);
|
|
145
|
+
return JSON.stringify(list);
|
|
146
|
+
}
|
|
147
|
+
exports.formatDepsString = formatDepsString;
|
|
148
|
+
function getMfHash(obj) {
|
|
149
|
+
return getHash(JSON.stringify(obj));
|
|
150
|
+
}
|
|
151
|
+
exports.getMfHash = getMfHash;
|
|
152
|
+
function commitMeta(appPath, metadataPath, metadata) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
// Todo: 改为相对路径
|
|
155
|
+
yield fs_extra_1.default.writeJSON(metadataPath, metadata, {
|
|
156
|
+
spaces: 2,
|
|
157
|
+
replacer(key, value) {
|
|
158
|
+
if (value instanceof Set) {
|
|
159
|
+
return Array.from(value);
|
|
160
|
+
}
|
|
161
|
+
if (key === 'taroRuntimeBundlePath') {
|
|
162
|
+
return path_1.default.relative(appPath, value);
|
|
163
|
+
}
|
|
164
|
+
return value;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
exports.commitMeta = commitMeta;
|
|
170
|
+
function getMeasure(isLogTiming) {
|
|
171
|
+
return function (name, start) {
|
|
172
|
+
if (isLogTiming) {
|
|
173
|
+
const now = perf_hooks_1.performance.now();
|
|
174
|
+
const duration = now - start;
|
|
175
|
+
console.log(helper_1.chalk.cyan(`${name}: ${Math.round(duration)}ms\n`));
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
exports.getMeasure = getMeasure;
|
|
180
|
+
__exportStar(require("./path"), exports);
|
|
181
|
+
__exportStar(require("./webpack"), exports);
|
|
182
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,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AA;IACJ,CAAC;CAAA;AAdD,gCAcC;AAED,SAAgB,UAAU,CAAE,WAAqB;IAC/C,OAAO,UAAU,IAAY,EAAE,KAAa;QAC1C,IAAI,WAAW,EAAE;YACf,MAAM,GAAG,GAAG,wBAAW,CAAC,GAAG,EAAE,CAAA;YAC7B,MAAM,QAAQ,GAAG,GAAG,GAAG,KAAK,CAAA;YAC5B,OAAO,CAAC,GAAG,CAAC,cAAK,CAAC,IAAI,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;SAChE;IACH,CAAC,CAAA;AACH,CAAC;AARD,gCAQC;AAED,yCAAsB;AACtB,4CAAyB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parsePublicPath = exports.addTrailingSlash = exports.addLeadingSlash = void 0;
|
|
4
|
+
const addLeadingSlash = (url = '') => (url.charAt(0) === '/' ? url : '/' + url);
|
|
5
|
+
exports.addLeadingSlash = addLeadingSlash;
|
|
6
|
+
const addTrailingSlash = (url = '') => (url.charAt(url.length - 1) === '/' ? url : url + '/');
|
|
7
|
+
exports.addTrailingSlash = addTrailingSlash;
|
|
8
|
+
function parsePublicPath(publicPath = '/') {
|
|
9
|
+
return ['', 'auto'].includes(publicPath) ? publicPath : (0, exports.addTrailingSlash)(publicPath);
|
|
10
|
+
}
|
|
11
|
+
exports.parsePublicPath = parsePublicPath;
|
|
12
|
+
//# sourceMappingURL=path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.js","sourceRoot":"","sources":["../../src/utils/path.ts"],"names":[],"mappings":";;;AAAO,MAAM,eAAe,GAAG,CAAC,GAAG,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAA;AAAzE,QAAA,eAAe,mBAA0D;AAC/E,MAAM,gBAAgB,GAAG,CAAC,GAAG,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAA;AAAvF,QAAA,gBAAgB,oBAAuE;AACpG,SAAgB,eAAe,CAAE,UAAU,GAAG,GAAG;IAC/C,OAAO,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAE,IAAA,wBAAgB,EAAC,UAAU,CAAC,CAAA;AACvF,CAAC;AAFD,0CAEC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Chunk, Compilation } from 'webpack';
|
|
2
|
+
import { ConcatSource, Source } from 'webpack-sources';
|
|
3
|
+
/**
|
|
4
|
+
* 在文本头部加入一些 require 语句
|
|
5
|
+
*/
|
|
6
|
+
export declare function addRequireToSource(id: string, modules: Source, commonChunks: (Chunk | {
|
|
7
|
+
name: string;
|
|
8
|
+
})[]): ConcatSource;
|
|
9
|
+
export declare function getChunkEntryModule(compilation: Compilation, chunk: Chunk): import("webpack").Module | undefined;
|
|
10
|
+
export declare function getChunkIdOrName(chunk: Chunk): string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getChunkIdOrName = exports.getChunkEntryModule = exports.addRequireToSource = void 0;
|
|
7
|
+
const helper_1 = require("@tarojs/helper");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const webpack_sources_1 = require("webpack-sources");
|
|
10
|
+
/**
|
|
11
|
+
* 在文本头部加入一些 require 语句
|
|
12
|
+
*/
|
|
13
|
+
function addRequireToSource(id, modules, commonChunks) {
|
|
14
|
+
const source = new webpack_sources_1.ConcatSource();
|
|
15
|
+
commonChunks.forEach(chunkItem => {
|
|
16
|
+
source.add(`require(${JSON.stringify((0, helper_1.promoteRelativePath)(path_1.default.relative(id, chunkItem.name)))});\n`);
|
|
17
|
+
});
|
|
18
|
+
source.add('\n');
|
|
19
|
+
source.add(modules);
|
|
20
|
+
source.add(';');
|
|
21
|
+
return source;
|
|
22
|
+
}
|
|
23
|
+
exports.addRequireToSource = addRequireToSource;
|
|
24
|
+
function getChunkEntryModule(compilation, chunk) {
|
|
25
|
+
const chunkGraph = compilation.chunkGraph;
|
|
26
|
+
const entryModules = Array.from(chunkGraph.getChunkEntryModulesIterable(chunk));
|
|
27
|
+
if (entryModules.length) {
|
|
28
|
+
return entryModules[0];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.getChunkEntryModule = getChunkEntryModule;
|
|
32
|
+
function getChunkIdOrName(chunk) {
|
|
33
|
+
if (typeof chunk.id === 'string') {
|
|
34
|
+
return chunk.id;
|
|
35
|
+
}
|
|
36
|
+
return chunk.name;
|
|
37
|
+
}
|
|
38
|
+
exports.getChunkIdOrName = getChunkIdOrName;
|
|
39
|
+
//# sourceMappingURL=webpack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webpack.js","sourceRoot":"","sources":["../../src/utils/webpack.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAoD;AACpD,gDAAuB;AAEvB,qDAAsD;AAEtD;;GAEG;AACH,SAAgB,kBAAkB,CAAE,EAAU,EAAE,OAAe,EAAE,YAA0C;IACzG,MAAM,MAAM,GAAG,IAAI,8BAAY,EAAE,CAAA;IACjC,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAC/B,MAAM,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,SAAS,CAAC,IAAA,4BAAmB,EAAC,cAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IACrG,CAAC,CAAC,CAAA;IACF,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAChB,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IACnB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACf,OAAO,MAAM,CAAA;AACf,CAAC;AATD,gDASC;AAED,SAAgB,mBAAmB,CAAE,WAAwB,EAAE,KAAY;IACzE,MAAM,UAAU,GAAG,WAAW,CAAC,UAAU,CAAA;IACzC,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC,CAAA;IAC/E,IAAI,YAAY,CAAC,MAAM,EAAE;QACvB,OAAO,YAAY,CAAC,CAAC,CAAC,CAAA;KACvB;AACH,CAAC;AAND,kDAMC;AAED,SAAgB,gBAAgB,CAAE,KAAY;IAC5C,IAAI,OAAO,KAAK,CAAC,EAAE,KAAK,QAAQ,EAAE;QAChC,OAAO,KAAK,CAAC,EAAE,CAAA;KAChB;IACD,OAAO,KAAK,CAAC,IAAI,CAAA;AACnB,CAAC;AALD,4CAKC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import ContainerPlugin from 'webpack/lib/container/ContainerPlugin';
|
|
2
|
+
declare const ContainerEntryModule: any;
|
|
3
|
+
declare type Exposes = ConstructorParameters<typeof ContainerPlugin>[0]['exposes'];
|
|
4
|
+
export default class TaroContainerEntryModule extends ContainerEntryModule {
|
|
5
|
+
constructor(name: string, exposes: Exposes, shareScope: string);
|
|
6
|
+
codeGeneration({ moduleGraph, chunkGraph, runtimeTemplate }: {
|
|
7
|
+
moduleGraph: any;
|
|
8
|
+
chunkGraph: any;
|
|
9
|
+
runtimeTemplate: any;
|
|
10
|
+
}): any;
|
|
11
|
+
}
|
|
12
|
+
export {};
|