@softarc/native-federation-esbuild 1.1.1 → 2.0.0
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/package.json +10 -9
- package/src/index.d.ts +1 -1
- package/src/index.js +4 -4
- package/src/lib/adapter.d.ts +16 -16
- package/src/lib/adapter.js +146 -132
- package/src/lib/adapter.js.map +1 -1
- package/src/lib/collect-exports.d.ts +6 -6
- package/src/lib/collect-exports.js +72 -71
- package/src/lib/collect-exports.js.map +1 -1
- package/src/lib/react-replacements.d.ts +2 -2
- package/src/lib/react-replacements.js +33 -33
package/package.json
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softarc/native-federation-esbuild",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@rollup/plugin-commonjs": "^22.0.2",
|
|
7
7
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
8
8
|
"@rollup/plugin-replace": "^4.0.0",
|
|
9
|
-
"
|
|
10
|
-
"rollup-plugin-node-externals": "^4.1.1",
|
|
9
|
+
"acorn": "^8.8.1",
|
|
11
10
|
"esbuild": "^0.15.5",
|
|
12
11
|
"npmlog": "^6.0.2",
|
|
13
|
-
"
|
|
12
|
+
"process": "0.11.10",
|
|
13
|
+
"rollup": "^2.79.0",
|
|
14
|
+
"rollup-plugin-node-externals": "^4.1.1"
|
|
14
15
|
},
|
|
15
|
-
"main": "./src/index.js",
|
|
16
|
-
"typings": "./src/index.d.ts",
|
|
17
16
|
"peerDependencies": {
|
|
18
|
-
"@softarc/native-federation": "
|
|
19
|
-
"@softarc/native-federation-runtime": "
|
|
20
|
-
}
|
|
17
|
+
"@softarc/native-federation": "2.0.0",
|
|
18
|
+
"@softarc/native-federation-runtime": "2.0.0"
|
|
19
|
+
},
|
|
20
|
+
"main": "./src/index.js",
|
|
21
|
+
"types": "./src/index.d.ts"
|
|
21
22
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './lib/adapter';
|
|
1
|
+
export * from './lib/adapter';
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./lib/adapter"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./lib/adapter"), exports);
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/src/lib/adapter.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { BuildAdapter, BuildAdapterOptions } from '@softarc/native-federation/build';
|
|
2
|
-
import * as esbuild from 'esbuild';
|
|
3
|
-
export declare const esBuildAdapter: BuildAdapter;
|
|
4
|
-
export
|
|
5
|
-
file: string;
|
|
6
|
-
};
|
|
7
|
-
export interface EsBuildAdapterConfig {
|
|
8
|
-
plugins: esbuild.Plugin[];
|
|
9
|
-
fileReplacements?: Record<string, string | ReplacementConfig>;
|
|
10
|
-
skipRollup?: boolean;
|
|
11
|
-
compensateExports?: RegExp[];
|
|
12
|
-
loader?: {
|
|
13
|
-
[ext: string]: esbuild.Loader;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export declare function createEsBuildAdapter(config: EsBuildAdapterConfig): (options: BuildAdapterOptions) => Promise<
|
|
1
|
+
import { BuildAdapter, BuildAdapterOptions, BuildResult } from '@softarc/native-federation/build';
|
|
2
|
+
import * as esbuild from 'esbuild';
|
|
3
|
+
export declare const esBuildAdapter: BuildAdapter;
|
|
4
|
+
export type ReplacementConfig = {
|
|
5
|
+
file: string;
|
|
6
|
+
};
|
|
7
|
+
export interface EsBuildAdapterConfig {
|
|
8
|
+
plugins: esbuild.Plugin[];
|
|
9
|
+
fileReplacements?: Record<string, string | ReplacementConfig>;
|
|
10
|
+
skipRollup?: boolean;
|
|
11
|
+
compensateExports?: RegExp[];
|
|
12
|
+
loader?: {
|
|
13
|
+
[ext: string]: esbuild.Loader;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export declare function createEsBuildAdapter(config: EsBuildAdapterConfig): (options: BuildAdapterOptions) => Promise<BuildResult[]>;
|
package/src/lib/adapter.js
CHANGED
|
@@ -1,133 +1,147 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createEsBuildAdapter = exports.esBuildAdapter = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
13
|
-
const commonjs = require('@rollup/plugin-commonjs');
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
15
|
-
const replace = require('@rollup/plugin-replace');
|
|
16
|
-
exports.esBuildAdapter = createEsBuildAdapter({
|
|
17
|
-
plugins: [],
|
|
18
|
-
});
|
|
19
|
-
function createEsBuildAdapter(config) {
|
|
20
|
-
if (!config.compensateExports) {
|
|
21
|
-
config.compensateExports = [new RegExp('/react/')];
|
|
22
|
-
}
|
|
23
|
-
return (options) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
});
|
|
56
|
-
const normEntryPoint = entryPoint.replace(/\\/g, '/');
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
yield
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
function
|
|
127
|
-
|
|
128
|
-
for (const key in
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createEsBuildAdapter = exports.esBuildAdapter = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const esbuild = tslib_1.__importStar(require("esbuild"));
|
|
6
|
+
const rollup_1 = require("rollup");
|
|
7
|
+
const plugin_node_resolve_1 = tslib_1.__importDefault(require("@rollup/plugin-node-resolve"));
|
|
8
|
+
const rollup_plugin_node_externals_1 = require("rollup-plugin-node-externals");
|
|
9
|
+
const collect_exports_1 = require("./collect-exports");
|
|
10
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
11
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
13
|
+
const commonjs = require('@rollup/plugin-commonjs');
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
15
|
+
const replace = require('@rollup/plugin-replace');
|
|
16
|
+
exports.esBuildAdapter = createEsBuildAdapter({
|
|
17
|
+
plugins: [],
|
|
18
|
+
});
|
|
19
|
+
function createEsBuildAdapter(config) {
|
|
20
|
+
if (!config.compensateExports) {
|
|
21
|
+
config.compensateExports = [new RegExp('/react/')];
|
|
22
|
+
}
|
|
23
|
+
return (options) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const { entryPoints, external, outdir, hash } = options;
|
|
25
|
+
// TODO: Do we need to prepare packages anymore as esbuild has evolved?
|
|
26
|
+
for (const entryPoint of entryPoints) {
|
|
27
|
+
const isPkg = entryPoint.fileName.includes('node_modules');
|
|
28
|
+
const pkgName = isPkg ? inferePkgName(entryPoint.fileName) : '';
|
|
29
|
+
const tmpFolder = `node_modules/.tmp/${pkgName}`;
|
|
30
|
+
if (isPkg) {
|
|
31
|
+
yield prepareNodePackage(entryPoint.fileName, external, tmpFolder, config, !!options.dev);
|
|
32
|
+
entryPoint.fileName = tmpFolder;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const ctx = yield esbuild.context({
|
|
36
|
+
entryPoints: entryPoints.map((ep) => ({
|
|
37
|
+
in: ep.fileName,
|
|
38
|
+
out: path_1.default.parse(ep.outName).name,
|
|
39
|
+
})),
|
|
40
|
+
write: false,
|
|
41
|
+
outdir,
|
|
42
|
+
entryNames: hash ? '[name]-[hash]' : '[name]',
|
|
43
|
+
external,
|
|
44
|
+
loader: config.loader,
|
|
45
|
+
bundle: true,
|
|
46
|
+
sourcemap: options.dev,
|
|
47
|
+
minify: !options.dev,
|
|
48
|
+
format: 'esm',
|
|
49
|
+
target: ['esnext'],
|
|
50
|
+
plugins: [...config.plugins],
|
|
51
|
+
});
|
|
52
|
+
const result = yield ctx.rebuild();
|
|
53
|
+
const writtenFiles = writeResult(result, outdir);
|
|
54
|
+
ctx.dispose();
|
|
55
|
+
return writtenFiles.map((fileName) => ({ fileName }));
|
|
56
|
+
// const normEntryPoint = entryPoint.replace(/\\/g, '/');
|
|
57
|
+
// if (
|
|
58
|
+
// isPkg &&
|
|
59
|
+
// config?.compensateExports?.find((regExp) => regExp.exec(normEntryPoint))
|
|
60
|
+
// ) {
|
|
61
|
+
// logger.verbose('compensate exports for ' + tmpFolder);
|
|
62
|
+
// compensateExports(tmpFolder, outfile);
|
|
63
|
+
// }
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
exports.createEsBuildAdapter = createEsBuildAdapter;
|
|
67
|
+
function writeResult(result, outdir) {
|
|
68
|
+
const outputFiles = result.outputFiles || [];
|
|
69
|
+
const writtenFiles = [];
|
|
70
|
+
for (const outFile of outputFiles) {
|
|
71
|
+
const fileName = path_1.default.basename(outFile.path);
|
|
72
|
+
const filePath = path_1.default.join(outdir, fileName);
|
|
73
|
+
fs.writeFileSync(filePath, outFile.text);
|
|
74
|
+
writtenFiles.push(filePath);
|
|
75
|
+
}
|
|
76
|
+
return writtenFiles;
|
|
77
|
+
}
|
|
78
|
+
function compensateExports(entryPoint, outfile) {
|
|
79
|
+
const inExports = (0, collect_exports_1.collectExports)(entryPoint);
|
|
80
|
+
const outExports = outfile ? (0, collect_exports_1.collectExports)(outfile) : inExports;
|
|
81
|
+
if (!outExports.hasDefaultExport || outExports.hasFurtherExports) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const defaultName = outExports.defaultExportName;
|
|
85
|
+
let exports = '/*Try to compensate missing exports*/\n\n';
|
|
86
|
+
for (const exp of inExports.exports) {
|
|
87
|
+
exports += `let ${exp}$softarc = ${defaultName}.${exp};\n`;
|
|
88
|
+
exports += `export { ${exp}$softarc as ${exp} };\n`;
|
|
89
|
+
}
|
|
90
|
+
const target = outfile !== null && outfile !== void 0 ? outfile : entryPoint;
|
|
91
|
+
fs.appendFileSync(target, exports, 'utf-8');
|
|
92
|
+
}
|
|
93
|
+
function prepareNodePackage(entryPoint, external, tmpFolder, config, dev) {
|
|
94
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
if (config.fileReplacements) {
|
|
96
|
+
entryPoint = replaceEntryPoint(entryPoint, normalize(config.fileReplacements));
|
|
97
|
+
}
|
|
98
|
+
const env = dev ? 'development' : 'production';
|
|
99
|
+
const result = yield (0, rollup_1.rollup)({
|
|
100
|
+
input: entryPoint,
|
|
101
|
+
plugins: [
|
|
102
|
+
commonjs(),
|
|
103
|
+
(0, rollup_plugin_node_externals_1.externals)({ include: external }),
|
|
104
|
+
(0, plugin_node_resolve_1.default)(),
|
|
105
|
+
replace({
|
|
106
|
+
preventAssignment: true,
|
|
107
|
+
values: {
|
|
108
|
+
'process.env.NODE_ENV': `"${env}"`,
|
|
109
|
+
},
|
|
110
|
+
}),
|
|
111
|
+
],
|
|
112
|
+
});
|
|
113
|
+
yield result.write({
|
|
114
|
+
format: 'esm',
|
|
115
|
+
file: tmpFolder,
|
|
116
|
+
sourcemap: dev,
|
|
117
|
+
exports: 'named',
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function inferePkgName(entryPoint) {
|
|
122
|
+
return entryPoint
|
|
123
|
+
.replace(/.*?node_modules/g, '')
|
|
124
|
+
.replace(/[^A-Za-z0-9.]/g, '_');
|
|
125
|
+
}
|
|
126
|
+
function normalize(config) {
|
|
127
|
+
const result = {};
|
|
128
|
+
for (const key in config) {
|
|
129
|
+
if (typeof config[key] === 'string') {
|
|
130
|
+
result[key] = {
|
|
131
|
+
file: config[key],
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
result[key] = config[key];
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
function replaceEntryPoint(entryPoint, fileReplacements) {
|
|
141
|
+
entryPoint = entryPoint.replace(/\\/g, '/');
|
|
142
|
+
for (const key in fileReplacements) {
|
|
143
|
+
entryPoint = entryPoint.replace(new RegExp(`${key}$`), fileReplacements[key].file);
|
|
144
|
+
}
|
|
145
|
+
return entryPoint;
|
|
146
|
+
}
|
|
133
147
|
//# sourceMappingURL=adapter.js.map
|
package/src/lib/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../../../libs/native-federation-esbuild/src/lib/adapter.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../../../libs/native-federation-esbuild/src/lib/adapter.ts"],"names":[],"mappings":";;;;AAMA,yDAAmC;AACnC,mCAAgC;AAChC,8FAAkD;AAClD,+EAAyD;AACzD,uDAAmD;AACnD,+CAAyB;AACzB,wDAAwB;AAExB,8DAA8D;AAC9D,MAAM,QAAQ,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AAEpD,8DAA8D;AAC9D,MAAM,OAAO,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAErC,QAAA,cAAc,GAAiB,oBAAoB,CAAC;IAC/D,OAAO,EAAE,EAAE;CACZ,CAAC,CAAC;AAcH,SAAgB,oBAAoB,CAAC,MAA4B;IAC/D,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE;QAC7B,MAA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,CAAC;QAEH,MAAM,MAAM,CAAC,KAAK,CAAC;YACjB,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,SAAS;YACf,SAAS,EAAE,GAAG;YACd,OAAO,EAAE,OAAO;SACjB,CAAC,CAAC;IACL,CAAC;CAAA;AAED,SAAS,aAAa,CAAC,UAAkB;IACvC,OAAO,UAAU;SACd,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;SAC/B,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;AACpC,CAAC;AAED,SAAS,SAAS,CAChB,MAAkD;IAElD,MAAM,MAAM,GAAsC,EAAE,CAAC;IACrD,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;QACxB,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE;YACnC,MAAM,CAAC,GAAG,CAAC,GAAG;gBACZ,IAAI,EAAE,MAAM,CAAC,GAAG,CAAW;aAC5B,CAAC;SACH;aAAM;YACL,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAsB,CAAC;SAChD;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,iBAAiB,CACxB,UAAkB,EAClB,gBAAmD;IAEnD,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAE5C,KAAK,MAAM,GAAG,IAAI,gBAAgB,EAAE;QAClC,UAAU,GAAG,UAAU,CAAC,OAAO,CAC7B,IAAI,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC,EACrB,gBAAgB,CAAC,GAAG,CAAC,CAAC,IAAI,CAC3B,CAAC;KACH;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare function collectExports(path: string): {
|
|
2
|
-
hasDefaultExport: boolean;
|
|
3
|
-
hasFurtherExports: boolean;
|
|
4
|
-
defaultExportName: string;
|
|
5
|
-
exports: string[];
|
|
6
|
-
};
|
|
1
|
+
export declare function collectExports(path: string): {
|
|
2
|
+
hasDefaultExport: boolean;
|
|
3
|
+
hasFurtherExports: boolean;
|
|
4
|
+
defaultExportName: string;
|
|
5
|
+
exports: string[];
|
|
6
|
+
};
|
|
@@ -1,72 +1,73 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.collectExports = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
let
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectExports = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
6
|
+
const acorn_1 = require("acorn");
|
|
7
|
+
function collectExports(path) {
|
|
8
|
+
const src = fs.readFileSync(path, 'utf8');
|
|
9
|
+
const parseTree = (0, acorn_1.parse)(src, {
|
|
10
|
+
ecmaVersion: 'latest',
|
|
11
|
+
allowHashBang: true,
|
|
12
|
+
sourceType: 'module',
|
|
13
|
+
});
|
|
14
|
+
let hasDefaultExport = false;
|
|
15
|
+
let hasFurtherExports = false;
|
|
16
|
+
let defaultExportName = '';
|
|
17
|
+
const exports = new Set();
|
|
18
|
+
traverse(parseTree, (node) => {
|
|
19
|
+
var _a, _b, _c, _d;
|
|
20
|
+
if (node.type === 'AssignmentExpression' &&
|
|
21
|
+
((_b = (_a = node === null || node === void 0 ? void 0 : node.left) === null || _a === void 0 ? void 0 : _a.object) === null || _b === void 0 ? void 0 : _b.name) === 'exports' // &&
|
|
22
|
+
) {
|
|
23
|
+
exports.add((_c = node.left.property) === null || _c === void 0 ? void 0 : _c.name);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (hasDefaultExport && hasFurtherExports) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (node.type !== 'ExportNamedDeclaration') {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (!node.specifiers) {
|
|
33
|
+
hasFurtherExports = true;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
for (const s of node.specifiers) {
|
|
37
|
+
if (isDefaultExport(s)) {
|
|
38
|
+
defaultExportName = (_d = s === null || s === void 0 ? void 0 : s.local) === null || _d === void 0 ? void 0 : _d.name;
|
|
39
|
+
hasDefaultExport = true;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
hasFurtherExports = true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
hasDefaultExport,
|
|
48
|
+
hasFurtherExports,
|
|
49
|
+
defaultExportName,
|
|
50
|
+
exports: [...exports],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
exports.collectExports = collectExports;
|
|
54
|
+
function traverse(node, visit) {
|
|
55
|
+
visit(node);
|
|
56
|
+
for (const key in node) {
|
|
57
|
+
const prop = node[key];
|
|
58
|
+
if (prop && typeof prop === 'object') {
|
|
59
|
+
traverse(prop, visit);
|
|
60
|
+
}
|
|
61
|
+
else if (Array.isArray(prop)) {
|
|
62
|
+
for (const sub of prop) {
|
|
63
|
+
traverse(sub, visit);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function isDefaultExport(exportSpecifier) {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
return (((_a = exportSpecifier.exported) === null || _a === void 0 ? void 0 : _a.type) === 'Identifier' &&
|
|
71
|
+
((_b = exportSpecifier.exported) === null || _b === void 0 ? void 0 : _b.name) === 'default');
|
|
72
|
+
}
|
|
72
73
|
//# sourceMappingURL=collect-exports.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collect-exports.js","sourceRoot":"","sources":["../../../../../libs/native-federation-esbuild/src/lib/collect-exports.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"collect-exports.js","sourceRoot":"","sources":["../../../../../libs/native-federation-esbuild/src/lib/collect-exports.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,iCAA8B;AAM9B,SAAgB,cAAc,CAAC,IAAY;IACzC,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAE1C,MAAM,SAAS,GAAG,IAAA,aAAK,EAAC,GAAG,EAAE;QAC3B,WAAW,EAAE,QAAQ;QACrB,aAAa,EAAE,IAAI;QACnB,UAAU,EAAE,QAAQ;KACrB,CAAC,CAAC;IAEH,IAAI,gBAAgB,GAAG,KAAK,CAAC;IAC7B,IAAI,iBAAiB,GAAG,KAAK,CAAC;IAC9B,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CAAC,CAAC;QACvB,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YACpC,QAAQ,CAAC,IAAY,EAAE,KAAK,CAAC,CAAC;SAC/B;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC9B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;gBACtB,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;aACtB;SACF;KACF;AACH,CAAC;AAED,SAAS,eAAe,CAAC,eAAqB;;IAC5C,OAAO,CACL,CAAA,MAAA,eAAe,CAAC,QAAQ,0CAAE,IAAI,MAAK,YAAY;QAC/C,CAAA,MAAA,eAAe,CAAC,QAAQ,0CAAE,IAAI,MAAK,SAAS,CAC7C,CAAC;AACJ,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ReplacementConfig } from './adapter';
|
|
2
|
-
export declare const reactReplacements: Record<string, Record<string, ReplacementConfig>>;
|
|
1
|
+
import { ReplacementConfig } from './adapter';
|
|
2
|
+
export declare const reactReplacements: Record<string, Record<string, ReplacementConfig>>;
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reactReplacements = void 0;
|
|
4
|
-
exports.reactReplacements = {
|
|
5
|
-
dev: {
|
|
6
|
-
'node_modules/react/index.js': {
|
|
7
|
-
file: 'node_modules/react/cjs/react.development.js',
|
|
8
|
-
},
|
|
9
|
-
'node_modules/react/jsx-dev-runtime.js': {
|
|
10
|
-
file: 'node_modules/react/cjs/react-jsx-dev-runtime.development.js',
|
|
11
|
-
},
|
|
12
|
-
'node_modules/react/jsx-runtime.js': {
|
|
13
|
-
file: 'node_modules/react/cjs/react-jsx-runtime.development.js',
|
|
14
|
-
},
|
|
15
|
-
'node_modules/react-dom/index.js': {
|
|
16
|
-
file: 'node_modules/react-dom/cjs/react-dom.development.js'
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
prod: {
|
|
20
|
-
'node_modules/react/index.js': {
|
|
21
|
-
file: 'node_modules/react/cjs/react.production.min.js',
|
|
22
|
-
},
|
|
23
|
-
'node_modules/react/jsx-dev-runtime.js': {
|
|
24
|
-
file: 'node_modules/react/cjs/react-jsx-dev-runtime.production.min.js',
|
|
25
|
-
},
|
|
26
|
-
'node_modules/react/jsx-runtime.js': {
|
|
27
|
-
file: 'node_modules/react/cjs/react-jsx-runtime.production.min.js',
|
|
28
|
-
},
|
|
29
|
-
'node_modules/react-dom/index.js': {
|
|
30
|
-
file: 'node_modules/react-dom/cjs/react-dom.production.min.js'
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reactReplacements = void 0;
|
|
4
|
+
exports.reactReplacements = {
|
|
5
|
+
dev: {
|
|
6
|
+
'node_modules/react/index.js': {
|
|
7
|
+
file: 'node_modules/react/cjs/react.development.js',
|
|
8
|
+
},
|
|
9
|
+
'node_modules/react/jsx-dev-runtime.js': {
|
|
10
|
+
file: 'node_modules/react/cjs/react-jsx-dev-runtime.development.js',
|
|
11
|
+
},
|
|
12
|
+
'node_modules/react/jsx-runtime.js': {
|
|
13
|
+
file: 'node_modules/react/cjs/react-jsx-runtime.development.js',
|
|
14
|
+
},
|
|
15
|
+
'node_modules/react-dom/index.js': {
|
|
16
|
+
file: 'node_modules/react-dom/cjs/react-dom.development.js',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
prod: {
|
|
20
|
+
'node_modules/react/index.js': {
|
|
21
|
+
file: 'node_modules/react/cjs/react.production.min.js',
|
|
22
|
+
},
|
|
23
|
+
'node_modules/react/jsx-dev-runtime.js': {
|
|
24
|
+
file: 'node_modules/react/cjs/react-jsx-dev-runtime.production.min.js',
|
|
25
|
+
},
|
|
26
|
+
'node_modules/react/jsx-runtime.js': {
|
|
27
|
+
file: 'node_modules/react/cjs/react-jsx-runtime.production.min.js',
|
|
28
|
+
},
|
|
29
|
+
'node_modules/react-dom/index.js': {
|
|
30
|
+
file: 'node_modules/react-dom/cjs/react-dom.production.min.js',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
34
|
//# sourceMappingURL=react-replacements.js.map
|