@softarc/native-federation-esbuild 0.0.1
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/README.md +4 -0
- package/package.json +15 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +5 -0
- package/src/index.js.map +1 -0
- package/src/lib/adapter.d.ts +2 -0
- package/src/lib/adapter.js +64 -0
- package/src/lib/adapter.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@softarc/native-federation-esbuild",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@rollup/plugin-commonjs": "^22.0.2",
|
|
7
|
+
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
8
|
+
"@rollup/plugin-replace": "^4.0.0",
|
|
9
|
+
"rollup": "^2.79.0",
|
|
10
|
+
"rollup-plugin-node-externals": "^4.1.1",
|
|
11
|
+
"esbuild": "^0.15.5"
|
|
12
|
+
},
|
|
13
|
+
"main": "./src/index.js",
|
|
14
|
+
"typings": "./src/index.d.ts"
|
|
15
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/adapter';
|
package/src/index.js
ADDED
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/native-federation-esbuild/src/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.esBuildAdapter = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const esbuild = require("esbuild");
|
|
6
|
+
const rollup_1 = require("rollup");
|
|
7
|
+
const plugin_node_resolve_1 = require("@rollup/plugin-node-resolve");
|
|
8
|
+
const rollup_plugin_node_externals_1 = require("rollup-plugin-node-externals");
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
10
|
+
const commonjs = require("@rollup/plugin-commonjs");
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
12
|
+
const replace = require("@rollup/plugin-replace");
|
|
13
|
+
const esBuildAdapter = (options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
const { entryPoint, external, outfile } = options;
|
|
15
|
+
const isPkg = entryPoint.includes("node_modules");
|
|
16
|
+
const pkgName = isPkg ? inferePkgName(entryPoint) : "";
|
|
17
|
+
const tmpFolder = `node_modules/.tmp/${pkgName}`;
|
|
18
|
+
if (isPkg) {
|
|
19
|
+
console.log('Preparing package ...');
|
|
20
|
+
yield prepareNodePackage(entryPoint, external, tmpFolder);
|
|
21
|
+
}
|
|
22
|
+
yield esbuild.build({
|
|
23
|
+
entryPoints: [isPkg ? tmpFolder : entryPoint],
|
|
24
|
+
external,
|
|
25
|
+
outfile,
|
|
26
|
+
bundle: true,
|
|
27
|
+
sourcemap: true,
|
|
28
|
+
minify: true,
|
|
29
|
+
format: "esm",
|
|
30
|
+
target: ["esnext"],
|
|
31
|
+
plugins: [],
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
exports.esBuildAdapter = esBuildAdapter;
|
|
35
|
+
function prepareNodePackage(entryPoint, external, tmpFolder) {
|
|
36
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const result = yield (0, rollup_1.rollup)({
|
|
38
|
+
input: entryPoint,
|
|
39
|
+
plugins: [
|
|
40
|
+
commonjs(),
|
|
41
|
+
(0, rollup_plugin_node_externals_1.externals)({ include: external }),
|
|
42
|
+
(0, plugin_node_resolve_1.default)(),
|
|
43
|
+
replace({
|
|
44
|
+
preventAssignment: true,
|
|
45
|
+
values: {
|
|
46
|
+
"process.env.NODE_ENV": '"development"',
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
49
|
+
],
|
|
50
|
+
});
|
|
51
|
+
yield result.write({
|
|
52
|
+
format: "esm",
|
|
53
|
+
file: tmpFolder,
|
|
54
|
+
sourcemap: true,
|
|
55
|
+
exports: "named",
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function inferePkgName(entryPoint) {
|
|
60
|
+
return entryPoint
|
|
61
|
+
.replace(/.*?node_modules/g, "")
|
|
62
|
+
.replace(/[^A-Za-z0-9\.]/g, "_");
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../../../libs/native-federation-esbuild/src/lib/adapter.ts"],"names":[],"mappings":";;;;AACA,mCAAmC;AACnC,mCAAgC;AAChC,qEAAkD;AAClD,+EAAyD;AAEzD,8DAA8D;AAC9D,MAAM,QAAQ,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AAEpD,8DAA8D;AAC9D,MAAM,OAAO,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAE3C,MAAM,cAAc,GAAiB,CAAO,OAAO,EAAE,EAAE;IAC5D,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAElD,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACvD,MAAM,SAAS,GAAG,qBAAqB,OAAO,EAAE,CAAC;IAEjD,IAAI,KAAK,EAAE;QACT,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;QAErC,MAAM,kBAAkB,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;KAC3D;IAED,MAAM,OAAO,CAAC,KAA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