@angular-architects/native-federation 0.9.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/README.md +259 -0
- package/builders.json +10 -0
- package/collection.json +17 -0
- package/config.d.ts +1 -0
- package/config.js +5 -0
- package/config.js.map +1 -0
- package/executors.json +10 -0
- package/generators.json +12 -0
- package/package.json +27 -0
- package/src/builders/build/builder.d.ts +5 -0
- package/src/builders/build/builder.js +224 -0
- package/src/builders/build/builder.js.map +1 -0
- package/src/builders/build/schema.d.ts +3 -0
- package/src/builders/build/schema.json +550 -0
- package/src/config/federation-config.d.ts +26 -0
- package/src/config/federation-config.js +3 -0
- package/src/config/federation-config.js.map +1 -0
- package/src/config/index.d.ts +2 -0
- package/src/config/index.js +10 -0
- package/src/config/index.js.map +1 -0
- package/src/config/with-native-federation.d.ts +2 -0
- package/src/config/with-native-federation.js +53 -0
- package/src/config/with-native-federation.js.map +1 -0
- package/src/config.d.ts +2 -0
- package/src/config.js +10 -0
- package/src/config.js.map +1 -0
- package/src/executors/build/executor.d.ts +4 -0
- package/src/executors/build/executor.js +13 -0
- package/src/executors/build/executor.js.map +1 -0
- package/src/executors/build/schema.d.ts +1 -0
- package/src/executors/build/schema.json +9 -0
- package/src/generators/native-federation/files/src/index.ts__template__ +1 -0
- package/src/generators/native-federation/generator.d.ts +3 -0
- package/src/generators/native-federation/generator.js +44 -0
- package/src/generators/native-federation/generator.js.map +1 -0
- package/src/generators/native-federation/schema.d.ts +5 -0
- package/src/generators/native-federation/schema.json +29 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +5 -0
- package/src/index.js.map +1 -0
- package/src/schematics/init/files/federation.config.js +19 -0
- package/src/schematics/init/schema.d.ts +6 -0
- package/src/schematics/init/schema.json +34 -0
- package/src/schematics/init/schematic.d.ts +4 -0
- package/src/schematics/init/schematic.js +174 -0
- package/src/schematics/init/schematic.js.map +1 -0
- package/src/utils/build-utils.d.ts +9 -0
- package/src/utils/build-utils.js +38 -0
- package/src/utils/build-utils.js.map +1 -0
- package/src/utils/hash-file.d.ts +1 -0
- package/src/utils/hash-file.js +13 -0
- package/src/utils/hash-file.js.map +1 -0
- package/src/utils/mapped-paths.d.ts +10 -0
- package/src/utils/mapped-paths.js +37 -0
- package/src/utils/mapped-paths.js.map +1 -0
- package/src/utils/package-info.d.ts +7 -0
- package/src/utils/package-info.js +94 -0
- package/src/utils/package-info.js.map +1 -0
- package/src/utils/shared-mappings-plugin.d.ts +3 -0
- package/src/utils/shared-mappings-plugin.js +29 -0
- package/src/utils/shared-mappings-plugin.js.map +1 -0
package/src/config.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shareAll = exports.share = exports.findRootTsConfigJson = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./config/with-native-federation"), exports);
|
|
6
|
+
var webpack_1 = require("@angular-architects/module-federation/webpack");
|
|
7
|
+
Object.defineProperty(exports, "findRootTsConfigJson", { enumerable: true, get: function () { return webpack_1.findRootTsConfigJson; } });
|
|
8
|
+
Object.defineProperty(exports, "share", { enumerable: true, get: function () { return webpack_1.share; } });
|
|
9
|
+
Object.defineProperty(exports, "shareAll", { enumerable: true, get: function () { return webpack_1.shareAll; } });
|
|
10
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../libs/native-federation/src/config.ts"],"names":[],"mappings":";;;;AAAA,0EAAgD;AAChD,yEAIuD;AAHrD,+GAAA,oBAAoB,OAAA;AACpB,gGAAA,KAAK,OAAA;AACL,mGAAA,QAAQ,OAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
function runExecutor(options, nowos) {
|
|
5
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
6
|
+
console.log('Executor ran for Build', options, nowos);
|
|
7
|
+
return {
|
|
8
|
+
success: true,
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
exports.default = runExecutor;
|
|
13
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../libs/native-federation/src/executors/build/executor.ts"],"names":[],"mappings":";;;AAEA,SAA8B,WAAW,CACvC,OAA4B,EAC5B,KAAc;;QAEd,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAEtD,OAAO;YACL,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;CAAA;AATD,8BASC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export interface BuildExecutorSchema {} // eslint-disable-line
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const variable = "<%= projectName %>";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const devkit_1 = require("@nrwl/devkit");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
function normalizeOptions(tree, options) {
|
|
7
|
+
const name = (0, devkit_1.names)(options.name).fileName;
|
|
8
|
+
const projectDirectory = options.directory
|
|
9
|
+
? `${(0, devkit_1.names)(options.directory).fileName}/${name}`
|
|
10
|
+
: name;
|
|
11
|
+
const projectName = projectDirectory.replace(new RegExp('/', 'g'), '-');
|
|
12
|
+
const projectRoot = `${(0, devkit_1.getWorkspaceLayout)(tree).libsDir}/${projectDirectory}`;
|
|
13
|
+
const parsedTags = options.tags
|
|
14
|
+
? options.tags.split(',').map((s) => s.trim())
|
|
15
|
+
: [];
|
|
16
|
+
return Object.assign(Object.assign({}, options), { projectName,
|
|
17
|
+
projectRoot,
|
|
18
|
+
projectDirectory,
|
|
19
|
+
parsedTags });
|
|
20
|
+
}
|
|
21
|
+
function addFiles(tree, options) {
|
|
22
|
+
const templateOptions = Object.assign(Object.assign(Object.assign({}, options), (0, devkit_1.names)(options.name)), { offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot), template: '' });
|
|
23
|
+
(0, devkit_1.generateFiles)(tree, path.join(__dirname, 'files'), options.projectRoot, templateOptions);
|
|
24
|
+
}
|
|
25
|
+
function default_1(tree, options) {
|
|
26
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const normalizedOptions = normalizeOptions(tree, options);
|
|
28
|
+
(0, devkit_1.addProjectConfiguration)(tree, normalizedOptions.projectName, {
|
|
29
|
+
root: normalizedOptions.projectRoot,
|
|
30
|
+
projectType: 'library',
|
|
31
|
+
sourceRoot: `${normalizedOptions.projectRoot}/src`,
|
|
32
|
+
targets: {
|
|
33
|
+
build: {
|
|
34
|
+
executor: '@angular-architects/native-federation:build',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
tags: normalizedOptions.parsedTags,
|
|
38
|
+
});
|
|
39
|
+
addFiles(tree, normalizedOptions);
|
|
40
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
exports.default = default_1;
|
|
44
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../libs/native-federation/src/generators/native-federation/generator.ts"],"names":[],"mappings":";;;AAAA,yCAQsB;AACtB,6BAA6B;AAU7B,SAAS,gBAAgB,CACvB,IAAU,EACV,OAAwC;IAExC,MAAM,IAAI,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IAC1C,MAAM,gBAAgB,GAAG,OAA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ACnC,WAAW,EAAE,SAAS;YACtB,UAAU,EAAE,GAAG,iBAAiB,CAAC,WAAW,MAAM;YAClD,OAAO,EAAE;gBACP,KAAK,EAAE;oBACL,QAAQ,EAAE,6CAA6C;iBACxD;aACF;YACD,IAAI,EAAE,iBAAiB,CAAC,UAAU;SACnC,CAAC,CAAC;QACH,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;QAClC,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AAlBD,4BAkBC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "NativeFederation",
|
|
5
|
+
"title": "",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"name": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "",
|
|
11
|
+
"$default": {
|
|
12
|
+
"$source": "argv",
|
|
13
|
+
"index": 0
|
|
14
|
+
},
|
|
15
|
+
"x-prompt": "What name would you like to use?"
|
|
16
|
+
},
|
|
17
|
+
"tags": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"description": "Add tags to the project (used for linting)",
|
|
20
|
+
"alias": "t"
|
|
21
|
+
},
|
|
22
|
+
"directory": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"description": "A directory where the project is placed",
|
|
25
|
+
"alias": "d"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"required": ["name"]
|
|
29
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@angular-architects/native-federation-runtime';
|
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/src/index.ts"],"names":[],"mappings":";;;AAAA,wFAA8D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const { withNativeFederation, shareAll } = require('@angular-architects/native-federation/config');
|
|
2
|
+
|
|
3
|
+
module.exports = withNativeFederation({
|
|
4
|
+
<% if (type === 'remote') { %>
|
|
5
|
+
name: '<%=project%>',
|
|
6
|
+
|
|
7
|
+
exposes: {
|
|
8
|
+
'./Component': './<%=projectSourceRoot%>/app/app.component.ts',
|
|
9
|
+
},
|
|
10
|
+
<% } else if (type === 'host') { %>
|
|
11
|
+
remotes: {<% for (key in remoteMap) { %>
|
|
12
|
+
"<%=key%>": "<%=remoteMap[key]%>",<% } %>
|
|
13
|
+
},
|
|
14
|
+
<% } %>
|
|
15
|
+
shared: {
|
|
16
|
+
...shareAll({ singleton: true, strictVersion: true, requiredVersion: 'auto' }),
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "mf",
|
|
4
|
+
"title": "",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"project": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The project to add module federation",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "argv",
|
|
12
|
+
"index": 0
|
|
13
|
+
},
|
|
14
|
+
"x-prompt": "Project name (press enter for default project)"
|
|
15
|
+
},
|
|
16
|
+
"port": {
|
|
17
|
+
"type": "number",
|
|
18
|
+
"description": "The port to use for the federated module (remote, micro frontend, etc.)",
|
|
19
|
+
"$default": {
|
|
20
|
+
"$source": "argv",
|
|
21
|
+
"index": 1
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"type": {
|
|
25
|
+
"enum": ["host", "dynamic-host", "remote"],
|
|
26
|
+
"type": "string",
|
|
27
|
+
"default": "remote"
|
|
28
|
+
},
|
|
29
|
+
"nxBuilders": {
|
|
30
|
+
"type": "boolean",
|
|
31
|
+
"description": "Use builders provided by Nx instead of ngx-build-plus? Defaults to true for Nx workspaces and false for CLI workspaces."
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWorkspaceFileName = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
|
+
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
7
|
+
const core_1 = require("@angular-devkit/core");
|
|
8
|
+
const dependencies_1 = require("@schematics/angular/utility/dependencies");
|
|
9
|
+
const path = require("path");
|
|
10
|
+
function config(options) {
|
|
11
|
+
return function (tree, context) {
|
|
12
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
const workspaceFileName = getWorkspaceFileName(tree);
|
|
14
|
+
const workspace = JSON.parse(tree.read(workspaceFileName).toString('utf8'));
|
|
15
|
+
const { polyfills, projectName, projectRoot, projectSourceRoot, manifestPath, projectConfig, main } = normalizeOptions(options, workspace);
|
|
16
|
+
updatePolyfills(tree, polyfills);
|
|
17
|
+
const remoteMap = yield generateRemoteMap(workspace, projectName);
|
|
18
|
+
if (options.type === 'dynamic-host') {
|
|
19
|
+
tree.create(manifestPath, JSON.stringify(remoteMap, null, '\t'));
|
|
20
|
+
}
|
|
21
|
+
const generateRule = yield generateFederationConfig(remoteMap, projectRoot, projectSourceRoot, options);
|
|
22
|
+
updateWorkspaceConfig(projectConfig, tree, workspaceFileName, workspace);
|
|
23
|
+
(0, dependencies_1.addPackageJsonDependency)(tree, {
|
|
24
|
+
name: 'es-module-shims',
|
|
25
|
+
type: dependencies_1.NodeDependencyType.Default,
|
|
26
|
+
version: '^1.5.12',
|
|
27
|
+
overwrite: false,
|
|
28
|
+
});
|
|
29
|
+
context.addTask(new tasks_1.NodePackageInstallTask());
|
|
30
|
+
return (0, schematics_1.chain)([
|
|
31
|
+
generateRule,
|
|
32
|
+
makeMainAsync(main, options, remoteMap),
|
|
33
|
+
]);
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
exports.default = config;
|
|
38
|
+
function updateWorkspaceConfig(projectConfig, tree, workspaceFileName, workspace) {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
if (!((_a = projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.architect) === null || _a === void 0 ? void 0 : _a.build) || !((_b = projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.architect) === null || _b === void 0 ? void 0 : _b.serve)) {
|
|
41
|
+
throw new Error(`The project doen't have a build or serve target in angular.json!`);
|
|
42
|
+
}
|
|
43
|
+
// TODO: When adding a builder for serve, we
|
|
44
|
+
// should set the port
|
|
45
|
+
// const port = parseInt(options.port);
|
|
46
|
+
// if (isNaN(port)) {
|
|
47
|
+
// throw new Error(`Port must be a number!`);
|
|
48
|
+
// }
|
|
49
|
+
if (!projectConfig.architect.build.options) {
|
|
50
|
+
projectConfig.architect.build.options = {};
|
|
51
|
+
}
|
|
52
|
+
if (!projectConfig.architect.serve.options) {
|
|
53
|
+
projectConfig.architect.serve.options = {};
|
|
54
|
+
}
|
|
55
|
+
projectConfig.architect.build.builder = '@angular-architects/native-federation:build';
|
|
56
|
+
// projectConfig.architect.serve.builder = serveBuilder;
|
|
57
|
+
// TODO: Register further builders when ready
|
|
58
|
+
tree.overwrite(workspaceFileName, JSON.stringify(workspace, null, '\t'));
|
|
59
|
+
}
|
|
60
|
+
function normalizeOptions(options, workspace) {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
if (!options.project) {
|
|
63
|
+
options.project = workspace.defaultProject;
|
|
64
|
+
}
|
|
65
|
+
if (!options.project) {
|
|
66
|
+
throw new Error(`No default project found. Please specifiy a project name!`);
|
|
67
|
+
}
|
|
68
|
+
const projectName = options.project;
|
|
69
|
+
const projectConfig = workspace.projects[projectName];
|
|
70
|
+
if (!projectConfig) {
|
|
71
|
+
throw new Error(`Project ${projectName} not found!`);
|
|
72
|
+
}
|
|
73
|
+
const projectRoot = (_a = projectConfig.root) === null || _a === void 0 ? void 0 : _a.replace(/\\/g, '/');
|
|
74
|
+
const projectSourceRoot = (_b = projectConfig.sourceRoot) === null || _b === void 0 ? void 0 : _b.replace(/\\/g, '/');
|
|
75
|
+
const manifestPath = path
|
|
76
|
+
.join(projectRoot, 'src/assets/federation.manifest.json')
|
|
77
|
+
.replace(/\\/g, '/');
|
|
78
|
+
const main = projectConfig.architect.build.options.main;
|
|
79
|
+
const polyfills = projectConfig.architect.build.options.polyfills;
|
|
80
|
+
return { polyfills, projectName, projectRoot, projectSourceRoot, manifestPath, projectConfig, main };
|
|
81
|
+
}
|
|
82
|
+
function updatePolyfills(tree, polyfills) {
|
|
83
|
+
let polyfillsContent = tree.readText(polyfills);
|
|
84
|
+
if (!polyfillsContent.includes('es-module-shims')) {
|
|
85
|
+
polyfillsContent += `\nimport 'es-module-shims';\n`;
|
|
86
|
+
tree.overwrite(polyfills, polyfillsContent);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function generateRemoteMap(workspace, projectName) {
|
|
90
|
+
var _a, _b, _c, _d, _e;
|
|
91
|
+
const result = {};
|
|
92
|
+
for (const p in workspace.projects) {
|
|
93
|
+
const project = workspace.projects[p];
|
|
94
|
+
const projectType = (_a = project.projectType) !== null && _a !== void 0 ? _a : 'application';
|
|
95
|
+
if (p !== projectName &&
|
|
96
|
+
projectType === 'application' &&
|
|
97
|
+
((_b = project === null || project === void 0 ? void 0 : project.architect) === null || _b === void 0 ? void 0 : _b.serve) &&
|
|
98
|
+
((_c = project === null || project === void 0 ? void 0 : project.architect) === null || _c === void 0 ? void 0 : _c.build)) {
|
|
99
|
+
const pPort = (_e = (_d = project.architect.serve.options) === null || _d === void 0 ? void 0 : _d.port) !== null && _e !== void 0 ? _e : 4200;
|
|
100
|
+
result[core_1.strings.camelize(p)] = `http://localhost:${pPort}/remoteEntry.json`;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (Object.keys(result).length === 0) {
|
|
104
|
+
result['mfe1'] = `http://localhost:3000/remoteEntry.json`;
|
|
105
|
+
}
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
function makeMainAsync(main, options, remoteMap) {
|
|
109
|
+
return function (tree, context) {
|
|
110
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const mainPath = path.dirname(main);
|
|
112
|
+
const bootstrapName = path.join(mainPath, 'bootstrap.ts');
|
|
113
|
+
if (tree.exists(bootstrapName)) {
|
|
114
|
+
console.info(`${bootstrapName} already exists.`);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const mainContent = tree.read(main);
|
|
118
|
+
tree.create(bootstrapName, mainContent);
|
|
119
|
+
let newMainContent = '';
|
|
120
|
+
if (options.type === 'dynamic-host') {
|
|
121
|
+
newMainContent = `import { initFederation } from '@angular-architects/native-federation';
|
|
122
|
+
|
|
123
|
+
initFederation('/assets/federation.manifest.json')
|
|
124
|
+
.catch(err => console.error(err))
|
|
125
|
+
.then(_ => import('./bootstrap'))
|
|
126
|
+
.catch(err => console.error(err));
|
|
127
|
+
`;
|
|
128
|
+
}
|
|
129
|
+
else if (options.type === 'host') {
|
|
130
|
+
const manifest = JSON.stringify(remoteMap, null, 2).replace(/"/g, '\'');
|
|
131
|
+
newMainContent = `import { initFederation } from '@angular-architects/native-federation';
|
|
132
|
+
|
|
133
|
+
initFederation(${manifest})
|
|
134
|
+
.catch(err => console.error(err))
|
|
135
|
+
.then(_ => import('./bootstrap'))
|
|
136
|
+
.catch(err => console.error(err));
|
|
137
|
+
`;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
newMainContent = `import { initFederation } from '@angular-architects/native-federation';
|
|
141
|
+
|
|
142
|
+
initFederation()
|
|
143
|
+
.catch(err => console.error(err))
|
|
144
|
+
.then(_ => import('./bootstrap'))
|
|
145
|
+
.catch(err => console.error(err));
|
|
146
|
+
`;
|
|
147
|
+
}
|
|
148
|
+
tree.overwrite(main, newMainContent);
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function getWorkspaceFileName(tree) {
|
|
153
|
+
if (tree.exists('angular.json')) {
|
|
154
|
+
return 'angular.json';
|
|
155
|
+
}
|
|
156
|
+
if (tree.exists('workspace.json')) {
|
|
157
|
+
return 'workspace.json';
|
|
158
|
+
}
|
|
159
|
+
throw new Error("angular.json or workspace.json expected! Did you call this in your project's root?");
|
|
160
|
+
}
|
|
161
|
+
exports.getWorkspaceFileName = getWorkspaceFileName;
|
|
162
|
+
function generateFederationConfig(remoteMap, projectRoot, projectSourceRoot, options) {
|
|
163
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
const tmpl = (0, schematics_1.url)('./files');
|
|
165
|
+
const applied = (0, schematics_1.apply)(tmpl, [
|
|
166
|
+
(0, schematics_1.template)(Object.assign({ projectRoot,
|
|
167
|
+
projectSourceRoot,
|
|
168
|
+
remoteMap }, options)),
|
|
169
|
+
(0, schematics_1.move)(projectRoot),
|
|
170
|
+
]);
|
|
171
|
+
return (0, schematics_1.mergeWith)(applied);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=schematic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schematic.js","sourceRoot":"","sources":["../../../../../../libs/native-federation/src/schematics/init/schematic.ts"],"names":[],"mappings":";;;;AAAA,2DASoC;AAEpC,4DAA0E;AAC1E,+CAA+C;AAG/C,2EAGkD;AAElD,6BAA6B;AAY7B,SAAwB,MAAM,CAAC,OAA0B;IACvD,OAAO,UAAgB,IAAI,EAAE,OAAO;;YAElC,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;YACrD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC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AAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACxE,cAAc,GAAG;;iBAEN,QAAQ;;;;CAIxB,CAAC;aAEG;iBACI;gBACH,cAAc,GAAG;;;;;;CAMtB,CAAC;aAEG;YAED,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QACvC,CAAC;KAAA,CAAC;AACJ,CAAC;AAED,SAAgB,oBAAoB,CAAC,IAAU;IAC7C,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE;QAC/B,OAAO,cAAc,CAAC;KACvB;IACD,IAAI,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE;QACjC,OAAO,gBAAgB,CAAC;KACzB;IACD,MAAM,IAAI,KAAK,CACb,oFAAoF,CACrF,CAAC;AACJ,CAAC;AAVD,oDAUC;AAED,SAAe,wBAAwB,CACrC,SAAiC,EACjC,WAAmB,EACnB,iBAAyB,EACzB,OAA0B;;QAE1B,MAAM,IAAI,GAAG,IAAA,gBAAG,EAAC,SAAS,CAAC,CAAC;QAE5B,MAAM,OAAO,GAAG,IAAA,kBAAK,EAAC,IAAI,EAAE;YAC1B,IAAA,qBAAQ,kBACN,WAAW;gBACX,iBAAiB;gBACjB,SAAS,IACN,OAAO,EACV;YACF,IAAA,iBAAI,EAAC,WAAW,CAAC;SAClB,CAAC,CAAC;QAEH,OAAO,IAAA,sBAAS,EAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MappedPath } from './mapped-paths';
|
|
2
|
+
export declare function bundle({ entryPoint, tsConfigPath, external, outfile, mappedPaths, useSharedMappingPlugin, }: {
|
|
3
|
+
entryPoint: string;
|
|
4
|
+
tsConfigPath: string;
|
|
5
|
+
external: Array<string>;
|
|
6
|
+
outfile: string;
|
|
7
|
+
mappedPaths: MappedPath[];
|
|
8
|
+
useSharedMappingPlugin: boolean;
|
|
9
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bundle = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const esbuild = require("esbuild");
|
|
6
|
+
const compiler_plugin_1 = require("@angular-devkit/build-angular/src/builders/browser-esbuild/compiler-plugin");
|
|
7
|
+
const shared_mappings_plugin_1 = require("./shared-mappings-plugin");
|
|
8
|
+
function bundle({ entryPoint, tsConfigPath, external, outfile, mappedPaths, useSharedMappingPlugin, }) {
|
|
9
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
10
|
+
yield esbuild.build({
|
|
11
|
+
entryPoints: [entryPoint],
|
|
12
|
+
external,
|
|
13
|
+
outfile,
|
|
14
|
+
bundle: true,
|
|
15
|
+
sourcemap: true,
|
|
16
|
+
minify: true,
|
|
17
|
+
format: 'esm',
|
|
18
|
+
target: ['esnext'],
|
|
19
|
+
plugins: [
|
|
20
|
+
(0, compiler_plugin_1.createCompilerPlugin)({
|
|
21
|
+
sourcemap: true,
|
|
22
|
+
tsconfig: tsConfigPath,
|
|
23
|
+
advancedOptimizations: true,
|
|
24
|
+
thirdPartySourcemaps: true,
|
|
25
|
+
}, {
|
|
26
|
+
optimization: true,
|
|
27
|
+
sourcemap: true,
|
|
28
|
+
workspaceRoot: __dirname,
|
|
29
|
+
}),
|
|
30
|
+
...(useSharedMappingPlugin
|
|
31
|
+
? [(0, shared_mappings_plugin_1.createSharedMappingsPlugin)(mappedPaths)]
|
|
32
|
+
: []),
|
|
33
|
+
],
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
exports.bundle = bundle;
|
|
38
|
+
//# sourceMappingURL=build-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-utils.js","sourceRoot":"","sources":["../../../../../libs/native-federation/src/utils/build-utils.ts"],"names":[],"mappings":";;;;AAAA,mCAAmC;AACnC,gHAAkH;AAElH,qEAAsE;AAEtE,SAAsB,MAAM,CAAC,EAC3B,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,WAAW,EACX,sBAAsB,GAQvB;;QACC,MAAM,OAAO,CAAC,KAAK,CAAC;YAClB,WAAW,EAAE,CAAC,UAAU,CAAC;YACzB,QAAQ;YACR,OAAO;YACP,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,CAAC,QAAQ,CAAC;YAClB,OAAO,EAAE;gBACP,IAAA,sCAAoB,EAClB;oBACE,SAAS,EAAE,IAAI;oBACf,QAAQ,EAAE,YAAY;oBACtB,qBAAqB,EAAE,IAAI;oBAC3B,oBAAoB,EAAE,IAAI;iBAC3B,EACD;oBACE,YAAY,EAAE,IAAI;oBAClB,SAAS,EAAE,IAAI;oBACf,aAAa,EAAE,SAAS;iBACzB,CACF;gBACD,GAAG,CAAC,sBAAsB;oBACxB,CAAC,CAAC,CAAC,IAAA,mDAA0B,EAAC,WAAW,CAAC,CAAC;oBAC3C,CAAC,CAAC,EAAE,CAAC;aACR;SACF,CAAC,CAAC;IACL,CAAC;CAAA;AA3CD,wBA2CC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hashFile(fileName: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hashFile = void 0;
|
|
4
|
+
const crypto = require("crypto");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
function hashFile(fileName) {
|
|
7
|
+
const fileBuffer = fs.readFileSync(fileName);
|
|
8
|
+
const hashSum = crypto.createHash('md5');
|
|
9
|
+
hashSum.update(fileBuffer);
|
|
10
|
+
return hashSum.digest('hex');
|
|
11
|
+
}
|
|
12
|
+
exports.hashFile = hashFile;
|
|
13
|
+
//# sourceMappingURL=hash-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash-file.js","sourceRoot":"","sources":["../../../../../libs/native-federation/src/utils/hash-file.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,yBAAyB;AAEzB,SAAgB,QAAQ,CAAC,QAAgB;IACvC,MAAM,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACzC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC3B,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AALD,4BAKC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface MappedPath {
|
|
2
|
+
key: string;
|
|
3
|
+
path: string;
|
|
4
|
+
}
|
|
5
|
+
export interface GetMappedPathsOptions {
|
|
6
|
+
rootTsConfigPath: string;
|
|
7
|
+
sharedMappings?: string[];
|
|
8
|
+
rootPath?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function getMappedPaths({ rootTsConfigPath, sharedMappings, rootPath, }: GetMappedPathsOptions): Array<MappedPath>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMappedPaths = void 0;
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const JSON5 = require("json5");
|
|
7
|
+
function getMappedPaths({ rootTsConfigPath, sharedMappings = null, rootPath, }) {
|
|
8
|
+
var _a;
|
|
9
|
+
const result = [];
|
|
10
|
+
if (!path.isAbsolute(rootTsConfigPath)) {
|
|
11
|
+
throw new Error('SharedMappings.register: tsConfigPath needs to be an absolute path!');
|
|
12
|
+
}
|
|
13
|
+
if (!rootPath) {
|
|
14
|
+
rootPath = path.normalize(path.dirname(rootTsConfigPath));
|
|
15
|
+
}
|
|
16
|
+
const shareAll = !sharedMappings;
|
|
17
|
+
if (!sharedMappings) {
|
|
18
|
+
sharedMappings = [];
|
|
19
|
+
}
|
|
20
|
+
const tsConfig = JSON5.parse(fs.readFileSync(rootTsConfigPath, { encoding: 'utf-8' }));
|
|
21
|
+
const mappings = (_a = tsConfig === null || tsConfig === void 0 ? void 0 : tsConfig.compilerOptions) === null || _a === void 0 ? void 0 : _a.paths;
|
|
22
|
+
if (!mappings) {
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
for (const key in mappings) {
|
|
26
|
+
const libPath = path.normalize(path.join(rootPath, mappings[key][0]));
|
|
27
|
+
if (sharedMappings.includes(key) || shareAll) {
|
|
28
|
+
result.push({
|
|
29
|
+
key,
|
|
30
|
+
path: libPath,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
exports.getMappedPaths = getMappedPaths;
|
|
37
|
+
//# sourceMappingURL=mapped-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapped-paths.js","sourceRoot":"","sources":["../../../../../libs/native-federation/src/utils/mapped-paths.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,yBAAyB;AACzB,+BAA+B;AAa/B,SAAgB,cAAc,CAAC,EAC7B,gBAAgB,EAChB,cAAc,GAAG,IAAI,EACrB,QAAQ,GACc;;IACtB,MAAM,MAAM,GAAsB,EAAE,CAAC;IAErC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QACtC,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;KACH;IAED,IAAI,CAAC,QAAQ,EAAE;QACb,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC;KAC3D;IACD,MAAM,QAAQ,GAAG,CAAC,cAAc,CAAC;IAEjC,IAAI,CAAC,cAAc,EAAE;QACnB,cAAc,GAAG,EAAE,CAAC;KACrB;IAED,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAC1B,EAAE,CAAC,YAAY,CAAC,gBAAgB,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CACzD,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,eAAe,0CAAE,KAAK,CAAC;IAElD,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,MAAM,CAAC;KACf;IAED,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE;QAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAEtE,IAAI,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,QAAQ,EAAE;YAC5C,MAAM,CAAC,IAAI,CAAC;gBACV,GAAG;gBACH,IAAI,EAAE,OAAO;aACd,CAAC,CAAC;SACJ;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AA5CD,wCA4CC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BuilderContext } from '@angular-devkit/architect';
|
|
2
|
+
export interface PackageInfo {
|
|
3
|
+
packageName: string;
|
|
4
|
+
entryPoint: string;
|
|
5
|
+
version: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function getPackageInfo(packageName: string, context: BuilderContext): PackageInfo | null;
|