@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,25 @@
|
|
|
1
|
+
import { Config } from '@swc/core';
|
|
2
|
+
import { parse } from 'es-module-lexer';
|
|
3
|
+
import esbuild, { Plugin } from 'esbuild';
|
|
4
|
+
import Chain from 'webpack-chain';
|
|
5
|
+
import { CollectedDeps } from '../utils/constant';
|
|
6
|
+
declare type ExportsData = ReturnType<typeof parse> & {
|
|
7
|
+
hasReExports?: boolean;
|
|
8
|
+
needInterop?: boolean;
|
|
9
|
+
};
|
|
10
|
+
interface BundleConfig {
|
|
11
|
+
appPath: string;
|
|
12
|
+
deps: CollectedDeps;
|
|
13
|
+
chain: Chain;
|
|
14
|
+
prebundleOutputDir: string;
|
|
15
|
+
customEsbuildConfig?: Record<string, any>;
|
|
16
|
+
customSwcConfig?: Config;
|
|
17
|
+
}
|
|
18
|
+
export declare function bundle({ appPath, deps, chain, prebundleOutputDir, customEsbuildConfig, customSwcConfig }: BundleConfig): Promise<esbuild.BuildResult & {
|
|
19
|
+
outputFiles: esbuild.OutputFile[];
|
|
20
|
+
}>;
|
|
21
|
+
export declare function getSwcPlugin({ appPath, flatIdExports }: {
|
|
22
|
+
appPath: string;
|
|
23
|
+
flatIdExports: Map<string, ExportsData>;
|
|
24
|
+
}, config?: Config): Plugin;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,188 @@
|
|
|
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.getSwcPlugin = exports.bundle = void 0;
|
|
16
|
+
const core_1 = require("@swc/core");
|
|
17
|
+
const helper_1 = require("@tarojs/helper");
|
|
18
|
+
const es_module_lexer_1 = require("es-module-lexer");
|
|
19
|
+
const esbuild_1 = __importDefault(require("esbuild"));
|
|
20
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
21
|
+
const lodash_1 = require("lodash");
|
|
22
|
+
const path_1 = __importDefault(require("path"));
|
|
23
|
+
const utils_1 = require("../utils");
|
|
24
|
+
const constant_1 = require("../utils/constant");
|
|
25
|
+
// esbuild generates nested directory output with lowest common ancestor base
|
|
26
|
+
// this is unpredictable and makes it difficult to analyze entry / output
|
|
27
|
+
// mapping. So what we do here is:
|
|
28
|
+
// 1. flatten all ids to eliminate slash
|
|
29
|
+
// 2. in the plugin, read the entry ourselves as virtual files to retain the
|
|
30
|
+
// path.
|
|
31
|
+
function bundle({ appPath, deps, chain, prebundleOutputDir, customEsbuildConfig = {}, customSwcConfig = {} }) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
yield es_module_lexer_1.init;
|
|
34
|
+
const flattenDeps = new Map();
|
|
35
|
+
const flatIdExports = new Map();
|
|
36
|
+
for (const [id, dep] of deps.entries()) {
|
|
37
|
+
// flatten id
|
|
38
|
+
const flatId = (0, utils_1.flattenId)(id);
|
|
39
|
+
flattenDeps.set(flatId, dep);
|
|
40
|
+
// Use es-module-lexer to check ES exports
|
|
41
|
+
// But "export * from" syntax should be checked alone
|
|
42
|
+
const fileContent = fs_extra_1.default.readFileSync(dep, 'utf-8');
|
|
43
|
+
const exportsData = (0, es_module_lexer_1.parse)(fileContent);
|
|
44
|
+
for (const { ss, se } of exportsData[0]) {
|
|
45
|
+
const exp = fileContent.slice(ss, se);
|
|
46
|
+
if (/export\s+\*\s+from/.test(exp)) {
|
|
47
|
+
exportsData.hasReExports = true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
flatIdExports.set(flatId, exportsData);
|
|
51
|
+
}
|
|
52
|
+
fs_extra_1.default.existsSync(prebundleOutputDir)
|
|
53
|
+
? fs_extra_1.default.emptyDirSync(prebundleOutputDir)
|
|
54
|
+
: fs_extra_1.default.ensureDirSync(prebundleOutputDir);
|
|
55
|
+
return esbuild_1.default.build(Object.assign(Object.assign({}, customEsbuildConfig), { absWorkingDir: appPath, bundle: true, write: false, entryPoints: Array.from(flattenDeps.keys()), mainFields: ['main:h5', 'browser', 'module', 'jsnext:main', 'main'], format: 'esm', loader: (0, lodash_1.defaults)(customEsbuildConfig.loader, constant_1.defaultEsbuildLoader), define: Object.assign(Object.assign({}, (0, utils_1.getDefines)(chain)), {
|
|
56
|
+
// AMD 被 esbuild 转 ESM 后,是套着 ESM 外皮的 AMD 语法模块。
|
|
57
|
+
// Webpack HarmonyDetectionParserPlugin 会阻止 AMDDefineDependencyParserPlugin 对这些模块的处理。
|
|
58
|
+
// 导致这些模块报错(如 lodash)。目前的办法是把 define 置为 false,不支持 AMD 导出。
|
|
59
|
+
define: 'false' }), splitting: true, metafile: true, ignoreAnnotations: true, outdir: prebundleOutputDir, plugins: [
|
|
60
|
+
getEntryPlugin({
|
|
61
|
+
flattenDeps,
|
|
62
|
+
flatIdExports,
|
|
63
|
+
prebundleOutputDir
|
|
64
|
+
}),
|
|
65
|
+
...customEsbuildConfig.plugins || [],
|
|
66
|
+
getSwcPlugin({ appPath, flatIdExports }, customSwcConfig)
|
|
67
|
+
] }));
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
exports.bundle = bundle;
|
|
71
|
+
function getEntryPlugin({ flattenDeps, flatIdExports, prebundleOutputDir }) {
|
|
72
|
+
const resolve = (0, utils_1.getResolve)();
|
|
73
|
+
return {
|
|
74
|
+
name: 'entry',
|
|
75
|
+
setup(build) {
|
|
76
|
+
// assets
|
|
77
|
+
build.onResolve({ filter: constant_1.assetsRE }, ({ path: id, importer }) => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
const filePath = yield resolve(path_1.default.dirname(importer), id);
|
|
79
|
+
const fileExt = path_1.default.extname(filePath);
|
|
80
|
+
const fileBasename = path_1.default.basename(filePath, fileExt);
|
|
81
|
+
const fileContent = yield fs_extra_1.default.readFile(filePath);
|
|
82
|
+
const outputFile = path_1.default.join(prebundleOutputDir, `${fileBasename}-${(0, utils_1.getHash)(filePath)}${fileExt}`);
|
|
83
|
+
yield fs_extra_1.default.writeFile(outputFile, fileContent);
|
|
84
|
+
return (0, utils_1.externalModule)({ path: `./${path_1.default.relative(prebundleOutputDir, outputFile)}` });
|
|
85
|
+
}));
|
|
86
|
+
build.onResolve({ filter: constant_1.moduleRE }, ({ path: id, importer }) => __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
// entry
|
|
88
|
+
if (!importer && flattenDeps.has(id)) {
|
|
89
|
+
return {
|
|
90
|
+
path: id,
|
|
91
|
+
namespace: 'entry'
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
const resolvedPath = yield resolve(path_1.default.dirname(importer), id);
|
|
96
|
+
if (typeof resolvedPath === 'string' && !constant_1.assetsRE.test(resolvedPath)) {
|
|
97
|
+
return { path: resolvedPath };
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
return (0, utils_1.externalModule)({ path: id });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
return (0, utils_1.externalModule)({ path: id });
|
|
105
|
+
}
|
|
106
|
+
}));
|
|
107
|
+
build.onLoad({ filter: constant_1.moduleRE, namespace: 'entry' }, ({ path: id }) => __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
var _a;
|
|
109
|
+
let js = '';
|
|
110
|
+
const filePath = (_a = flattenDeps.get(id)) === null || _a === void 0 ? void 0 : _a.replace(/\\/g, '\\\\');
|
|
111
|
+
const exportsData = flatIdExports.get(id);
|
|
112
|
+
const [importsList, exportsList] = exportsData;
|
|
113
|
+
const hasReExports = exportsData.hasReExports;
|
|
114
|
+
if (!importsList.length && !exportsList.length) {
|
|
115
|
+
/** CommonJS */
|
|
116
|
+
exportsData.needInterop = true;
|
|
117
|
+
js = `module.exports = require("${filePath}")`;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
/** ESM */
|
|
121
|
+
if (exportsList.includes('default')) {
|
|
122
|
+
// export default
|
|
123
|
+
js += `import d from "${filePath}";export default d;`;
|
|
124
|
+
}
|
|
125
|
+
if (hasReExports ||
|
|
126
|
+
exportsList.length > 1 ||
|
|
127
|
+
exportsList[0] !== 'default') {
|
|
128
|
+
// export * from 'xx'
|
|
129
|
+
// export const xx
|
|
130
|
+
js += `export * from "${filePath}";`;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// console.log('\n[debug] found entry: ', id)
|
|
134
|
+
// console.log('[debug]: filePath', filePath)
|
|
135
|
+
// console.log('[debug] importsData: ', flatIdExports.get(id))
|
|
136
|
+
// console.log('[debug] js: ', js)
|
|
137
|
+
return {
|
|
138
|
+
loader: 'js',
|
|
139
|
+
resolveDir: process.cwd(),
|
|
140
|
+
contents: js
|
|
141
|
+
};
|
|
142
|
+
}));
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function getSwcPlugin({ appPath, flatIdExports }, config) {
|
|
147
|
+
return {
|
|
148
|
+
name: 'swc-plugin',
|
|
149
|
+
setup(build) {
|
|
150
|
+
build.onEnd(({ outputFiles = [], metafile = {} }) => __awaiter(this, void 0, void 0, function* () {
|
|
151
|
+
var _a, _b;
|
|
152
|
+
yield Promise.all(outputFiles.map(({ path, text }) => __awaiter(this, void 0, void 0, function* () {
|
|
153
|
+
if (!helper_1.REG_SCRIPTS.test(path))
|
|
154
|
+
return;
|
|
155
|
+
const { code } = (0, core_1.transformSync)(text, (0, lodash_1.defaults)(config, { jsc: { target: 'es2015' } }));
|
|
156
|
+
fs_extra_1.default.writeFile(path, code);
|
|
157
|
+
})));
|
|
158
|
+
// esbuild 把 Commonjs 转 ESM 时,打包后只有 export default 语句,
|
|
159
|
+
// 无法实现原模块 module.exports = 的功能。
|
|
160
|
+
// 因此使用一个 CommonJS 规范的中间模块进行处理。
|
|
161
|
+
const processAll = [];
|
|
162
|
+
const metaOutput = metafile.outputs;
|
|
163
|
+
for (const outputName in metaOutput) {
|
|
164
|
+
const output = metaOutput[outputName];
|
|
165
|
+
if (!((_a = output.entryPoint) === null || _a === void 0 ? void 0 : _a.startsWith('entry:')))
|
|
166
|
+
continue;
|
|
167
|
+
const entry = output.entryPoint.replace(/^entry:/, '');
|
|
168
|
+
if (!flatIdExports.has(entry))
|
|
169
|
+
continue;
|
|
170
|
+
if (((_b = flatIdExports.get(entry)) === null || _b === void 0 ? void 0 : _b.needInterop) &&
|
|
171
|
+
output.exports.length === 1 &&
|
|
172
|
+
output.exports[0] === 'default') {
|
|
173
|
+
const srcPath = path_1.default.join(appPath, outputName);
|
|
174
|
+
const destPath = path_1.default.join(appPath, outputName.replace(/(\.js)$/, '.core$1'));
|
|
175
|
+
processAll.push(fs_extra_1.default.move(srcPath, destPath)
|
|
176
|
+
.then(() => fs_extra_1.default.writeFile(srcPath, `const m = require('./${path_1.default.basename(destPath)}')
|
|
177
|
+
module.exports = m.default
|
|
178
|
+
exports.default = module.exports
|
|
179
|
+
`)));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
yield Promise.all(processAll);
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
exports.getSwcPlugin = getSwcPlugin;
|
|
188
|
+
//# sourceMappingURL=bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../src/prebundle/bundle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oCAAiD;AACjD,2CAA4C;AAC5C,qDAA6C;AAC7C,sDAAyC;AACzC,wDAAyB;AACzB,mCAAiC;AACjC,gDAAuB;AAGvB,oCAMiB;AACjB,gDAA2F;AAa3F,6EAA6E;AAC7E,yEAAyE;AACzE,kCAAkC;AAClC,wCAAwC;AACxC,4EAA4E;AAC5E,WAAW;AACX,SAAsB,MAAM,CAAE,EAC5B,OAAO,EACP,IAAI,EACJ,KAAK,EACL,kBAAkB,EAClB,mBAAmB,GAAG,EAAE,EACxB,eAAe,GAAG,EAAE,EACP;;QACb,MAAM,sBAAI,CAAA;QAEV,MAAM,WAAW,GAAkB,IAAI,GAAG,EAAE,CAAA;QAC5C,MAAM,aAAa,GAAG,IAAI,GAAG,EAAuB,CAAA;QAEpD,KAAK,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE;YACtC,aAAa;YACb,MAAM,MAAM,GAAG,IAAA,iBAAS,EAAC,EAAE,CAAC,CAAA;YAC5B,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;YAC5B,0CAA0C;YAC1C,qDAAqD;YACrD,MAAM,WAAW,GA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CACb,kBAAE,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC;6BACvB,IAAI,CAAC,GAAG,EAAE,CAAC,kBAAE,CAAC,SAAS,CACtB,OAAO,EACP,wBAAwB,cAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;;;CAGhE,CACgB,CAAC,CACL,CAAA;qBACF;iBACF;gBAED,MAAM,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;YAC/B,CAAC,CAAA,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC;AAxDD,oCAwDC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Config } from '@swc/core';
|
|
2
|
+
import { IProjectBaseConfig } from '@tarojs/taro/types/compile';
|
|
3
|
+
import { Message } from 'esbuild';
|
|
4
|
+
import { EntryObject } from 'webpack';
|
|
5
|
+
import Chain from 'webpack-chain';
|
|
6
|
+
import { getMeasure, Metadata } from '../utils';
|
|
7
|
+
import { CollectedDeps } from '../utils/constant';
|
|
8
|
+
export declare type IPrebundle = Exclude<IProjectBaseConfig['compiler'], string | undefined>['prebundle'];
|
|
9
|
+
export interface IPrebundleConfig {
|
|
10
|
+
appPath: string;
|
|
11
|
+
chain: Chain;
|
|
12
|
+
chunkFilename?: string;
|
|
13
|
+
enableSourceMap: boolean;
|
|
14
|
+
entry: EntryObject;
|
|
15
|
+
entryFileName?: string;
|
|
16
|
+
env: string;
|
|
17
|
+
sourceRoot: string;
|
|
18
|
+
}
|
|
19
|
+
export default class BasePrebundle<T extends IPrebundleConfig = IPrebundleConfig> {
|
|
20
|
+
protected config: T;
|
|
21
|
+
protected option: IPrebundle;
|
|
22
|
+
sourceRoot: string;
|
|
23
|
+
appPath: string;
|
|
24
|
+
cacheDir: string;
|
|
25
|
+
chain: Chain;
|
|
26
|
+
customEsbuildConfig: IPrebundle['esbuild'];
|
|
27
|
+
customSwcConfig?: Config;
|
|
28
|
+
env: string;
|
|
29
|
+
prebundleCacheDir: string;
|
|
30
|
+
remoteCacheDir: string;
|
|
31
|
+
metadataPath: string;
|
|
32
|
+
metadata: Metadata;
|
|
33
|
+
preMetadata: Metadata;
|
|
34
|
+
isUseCache: boolean;
|
|
35
|
+
deps: CollectedDeps;
|
|
36
|
+
measure: ReturnType<typeof getMeasure>;
|
|
37
|
+
constructor(config: T, option: IPrebundle);
|
|
38
|
+
run(): Promise<void>;
|
|
39
|
+
addPlugin(name: string, plugin: any, ...args: Record<string, any>[]): void;
|
|
40
|
+
get entryPath(): string;
|
|
41
|
+
parseEntries(entry?: EntryObject): string[];
|
|
42
|
+
/** 找出所有 webpack entry */
|
|
43
|
+
getEntries(appJsPath: string): string[];
|
|
44
|
+
setDeps(entries: string[], include?: string[], exclude?: string[]): Promise<void>;
|
|
45
|
+
bundle(): any;
|
|
46
|
+
handleBundleError(errors?: Message[]): any;
|
|
47
|
+
setHost(): void;
|
|
48
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
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
|
+
const helper_1 = require("@tarojs/helper");
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const perf_hooks_1 = require("perf_hooks");
|
|
18
|
+
const utils_1 = require("../utils");
|
|
19
|
+
const constant_1 = require("../utils/constant");
|
|
20
|
+
const TaroModuleFederationPlugin_1 = __importDefault(require("../webpack/TaroModuleFederationPlugin"));
|
|
21
|
+
const bundle_1 = require("./bundle");
|
|
22
|
+
const scanImports_1 = require("./scanImports");
|
|
23
|
+
class BasePrebundle {
|
|
24
|
+
constructor(config, option) {
|
|
25
|
+
this.config = config;
|
|
26
|
+
this.option = option;
|
|
27
|
+
this.isUseCache = true;
|
|
28
|
+
this.deps = new Map();
|
|
29
|
+
if (!option.enable)
|
|
30
|
+
return;
|
|
31
|
+
const { appPath, env, chain, sourceRoot } = this.config;
|
|
32
|
+
const { cacheDir = (0, utils_1.getCacheDir)(appPath, env), esbuild = {}, force, swc } = this.option;
|
|
33
|
+
this.chain = chain;
|
|
34
|
+
this.sourceRoot = sourceRoot;
|
|
35
|
+
this.appPath = appPath;
|
|
36
|
+
this.cacheDir = cacheDir;
|
|
37
|
+
this.customEsbuildConfig = esbuild;
|
|
38
|
+
this.customSwcConfig = swc;
|
|
39
|
+
this.env = env;
|
|
40
|
+
this.prebundleCacheDir = path_1.default.resolve(cacheDir, './prebundle');
|
|
41
|
+
this.remoteCacheDir = path_1.default.resolve(cacheDir, './remote');
|
|
42
|
+
this.metadataPath = path_1.default.join(cacheDir, 'metadata.json');
|
|
43
|
+
this.metadata = {};
|
|
44
|
+
this.preMetadata = {};
|
|
45
|
+
this.measure = (0, utils_1.getMeasure)(this.option.timings);
|
|
46
|
+
try {
|
|
47
|
+
if (force !== true) {
|
|
48
|
+
Object.assign(this.preMetadata, helper_1.fs.readJSONSync(this.metadataPath));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (e) { }
|
|
52
|
+
}
|
|
53
|
+
run() {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
if (!this.isUseCache) {
|
|
56
|
+
(0, utils_1.commitMeta)(this.appPath, this.metadataPath, this.metadata);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
addPlugin(name, plugin, ...args) {
|
|
61
|
+
this.chain.plugin(name).use(plugin, args);
|
|
62
|
+
}
|
|
63
|
+
get entryPath() {
|
|
64
|
+
const { entryFileName = 'app', entry = {} } = this.config;
|
|
65
|
+
const appJsPath = entry[entryFileName] || '';
|
|
66
|
+
if (typeof appJsPath === 'string') {
|
|
67
|
+
return appJsPath;
|
|
68
|
+
}
|
|
69
|
+
else if (appJsPath instanceof Array) {
|
|
70
|
+
return appJsPath[0];
|
|
71
|
+
}
|
|
72
|
+
else if (typeof appJsPath.import === 'string') {
|
|
73
|
+
return appJsPath.import;
|
|
74
|
+
}
|
|
75
|
+
return '';
|
|
76
|
+
}
|
|
77
|
+
parseEntries(entry = {}) {
|
|
78
|
+
const entries = [];
|
|
79
|
+
Object.values(entry).forEach(e => {
|
|
80
|
+
if (typeof e === 'string') {
|
|
81
|
+
entries.push(e);
|
|
82
|
+
}
|
|
83
|
+
else if (e instanceof Array) {
|
|
84
|
+
entries.push(...this.parseEntries(e));
|
|
85
|
+
}
|
|
86
|
+
else if (typeof e.import === 'string') {
|
|
87
|
+
entries.push(e.import);
|
|
88
|
+
}
|
|
89
|
+
else if (e.import instanceof Array) {
|
|
90
|
+
entries.push(...this.parseEntries(e.import));
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return entries;
|
|
94
|
+
}
|
|
95
|
+
/** 找出所有 webpack entry */
|
|
96
|
+
getEntries(appJsPath) {
|
|
97
|
+
const { appPath, sourceRoot } = this.config;
|
|
98
|
+
const entries = this.parseEntries(this.config.entry);
|
|
99
|
+
const appConfigPath = (0, helper_1.resolveMainFilePath)(`${appJsPath.replace(path_1.default.extname(appJsPath), '')}.config`);
|
|
100
|
+
if (helper_1.fs.existsSync(appConfigPath)) {
|
|
101
|
+
const appConfig = (0, helper_1.readConfig)(appConfigPath);
|
|
102
|
+
appConfig.pages.forEach((page) => {
|
|
103
|
+
const pageJsPath = (0, helper_1.resolveMainFilePath)(path_1.default.join(appPath, sourceRoot, page));
|
|
104
|
+
entries.push(pageJsPath);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return entries;
|
|
108
|
+
}
|
|
109
|
+
setDeps(entries, include = [], exclude = []) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const SCAN_START = perf_hooks_1.performance.now();
|
|
112
|
+
yield (0, scanImports_1.scanImports)({
|
|
113
|
+
appPath: this.appPath,
|
|
114
|
+
customEsbuildConfig: this.customEsbuildConfig,
|
|
115
|
+
entries,
|
|
116
|
+
include,
|
|
117
|
+
exclude,
|
|
118
|
+
}, this.deps);
|
|
119
|
+
this.deps.size &&
|
|
120
|
+
console.log(helper_1.chalk.cyan('Prebundle dependencies: \n', ...Array.from(this.deps.keys()).sort(utils_1.sortDeps).map(dep => ` ${dep}\n`)));
|
|
121
|
+
this.measure('Scan imports duration', SCAN_START);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
bundle() {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
const PREBUNDLE_START = perf_hooks_1.performance.now();
|
|
127
|
+
this.metadata.bundleHash = yield (0, utils_1.getBundleHash)(this.appPath, this.deps, this.chain, this.cacheDir);
|
|
128
|
+
if (this.preMetadata.bundleHash !== this.metadata.bundleHash) {
|
|
129
|
+
this.isUseCache = false;
|
|
130
|
+
try {
|
|
131
|
+
yield (0, bundle_1.bundle)({
|
|
132
|
+
appPath: this.appPath,
|
|
133
|
+
deps: this.deps,
|
|
134
|
+
chain: this.chain,
|
|
135
|
+
prebundleOutputDir: this.prebundleCacheDir,
|
|
136
|
+
customEsbuildConfig: this.customEsbuildConfig,
|
|
137
|
+
customSwcConfig: this.customSwcConfig,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
catch (result) {
|
|
141
|
+
return this.handleBundleError(result === null || result === void 0 ? void 0 : result.errors);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
this.measure('Prebundle duration', PREBUNDLE_START);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
handleBundleError(errors = []) {
|
|
148
|
+
const keys = Array.from(this.deps.keys());
|
|
149
|
+
if (errors.length > 0) {
|
|
150
|
+
const deps = errors.reduce((p, e) => {
|
|
151
|
+
var _a;
|
|
152
|
+
const file = ((_a = e.location) === null || _a === void 0 ? void 0 : _a.file) || '';
|
|
153
|
+
const key = keys.find(key => file === null || file === void 0 ? void 0 : file.includes(key));
|
|
154
|
+
if (key)
|
|
155
|
+
p.push(key);
|
|
156
|
+
return p;
|
|
157
|
+
}, []);
|
|
158
|
+
deps.forEach(key => this.deps.delete(key));
|
|
159
|
+
if (deps.length > 0) {
|
|
160
|
+
console.log(helper_1.chalk.yellowBright(`检测到依赖编译错误,已跳过`, deps.sort(utils_1.sortDeps).map(e => helper_1.chalk.bold(e)).join('、'), `依赖预编译。`, `\n > 可以通过手动配置 ${(0, helper_1.terminalLink)('compiler.prebundle.exclude', 'https://nervjs.github.io/taro-docs/docs/next/config-detail#compilerprebundleexclude')} 忽略该提示`));
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
console.log(helper_1.chalk.yellowBright(...errors));
|
|
164
|
+
}
|
|
165
|
+
return this.bundle();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
setHost() {
|
|
169
|
+
this.chain
|
|
170
|
+
.plugin('TaroModuleFederationPlugin')
|
|
171
|
+
.use(TaroModuleFederationPlugin_1.default, [{
|
|
172
|
+
name: 'taro-app',
|
|
173
|
+
remotes: {
|
|
174
|
+
[constant_1.MF_NAME]: `${constant_1.MF_NAME}@remoteEntry.js`
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
deps: this.deps,
|
|
179
|
+
env: this.env,
|
|
180
|
+
remoteAssets: this.metadata.remoteAssets,
|
|
181
|
+
runtimeRequirements: this.metadata.runtimeRequirements || new Set()
|
|
182
|
+
}]);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
exports.default = BasePrebundle;
|
|
186
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prebundle/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,2CAAyF;AAGzF,gDAAuB;AACvB,2CAAwC;AAIxC,oCAAiG;AACjG,gDAA0D;AAC1D,uGAA8E;AAC9E,qCAAiC;AACjC,+CAA2C;AAe3C,MAAqB,aAAa;IAkBhC,YAAuB,MAAS,EAAY,MAAkB;QAAvC,WAAM,GAAN,MAAM,CAAG;QAAY,WAAM,GAAN,MAAM,CAAY;QAL9D,eAAU,GAAG,IAAI,CAAA;QAEjB,SAAI,GAAkB,IAAI,GAAG,EAAE,CAAA;QAI7B,IAAI,CAAC,MAAM,CAAC,MAAM;YAAE,OAAM;QAE1B,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;QACvD,MAAM,EAAE,QAAQ,GAAG,IAAA,mBAAW,EAAC,OAAO,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;QAEtF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAA;QAClC,IAAI,CAAC,eAAe,GAAG,GAAG,CAAA;QAC1B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,iBAAiB,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,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AAC,CAAA;IACP,CAAC;CACF;AA9LD,gCA8LC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CollectedDeps } from '../utils/constant';
|
|
2
|
+
interface ScanImportsConfig {
|
|
3
|
+
appPath: string;
|
|
4
|
+
entries: string[];
|
|
5
|
+
include: string[];
|
|
6
|
+
exclude: string[];
|
|
7
|
+
customEsbuildConfig?: Record<string, any>;
|
|
8
|
+
}
|
|
9
|
+
export declare function scanImports({ appPath, entries, include, exclude, customEsbuildConfig }: ScanImportsConfig, deps?: CollectedDeps): Promise<CollectedDeps>;
|
|
10
|
+
export {};
|