Skip to content

Commit fb06cd9

Browse files
committed
fix: remove schematic takes care of missing props
1 parent feaecbd commit fb06cd9

File tree

14 files changed

+51
-118
lines changed

14 files changed

+51
-118
lines changed

libs/mf-runtime/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@angular-architects/module-federation-runtime",
33
"license": "MIT",
4-
"version": "18.0.4",
4+
"version": "18.0.5",
55
"peerDependencies": {
66
"@angular/common": ">=18.0.0",
77
"@angular/core": ">=18.0.0"

libs/mf-tools/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular-architects/module-federation-tools",
3-
"version": "18.0.4",
3+
"version": "18.0.5",
44
"license": "MIT",
55
"peerDependencies": {},
66
"dependencies": {

libs/mf/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular-architects/module-federation",
3-
"version": "18.0.4",
3+
"version": "18.0.5",
44
"license": "MIT",
55
"repository": {
66
"type": "GitHub",
@@ -17,7 +17,7 @@
1717
"schematics": "./collection.json",
1818
"builders": "./builders.json",
1919
"dependencies": {
20-
"@angular-architects/module-federation-runtime": "18.0.4",
20+
"@angular-architects/module-federation-runtime": "18.0.5",
2121
"word-wrap": "^1.2.3",
2222
"callsite": "^1.0.0",
2323
"node-fetch": "^2.6.7",

libs/mf/src/schematics/remove/schematic.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,21 @@ function updateServeConfig(normalized: {
4444
delete serve.options.extraWebpackConfig;
4545
delete serve.options.customWebpackConfig;
4646

47-
const serveProd = serve.configurations.production;
48-
delete serveProd.extraWebpackConfig;
49-
delete serveProd.customWebpackConfig;
47+
const serveProd = serve?.configurations?.production;
48+
49+
if (serveProd) {
50+
delete serveProd.extraWebpackConfig;
51+
delete serveProd.customWebpackConfig;
52+
}
53+
const prodTarget = serveProd?.browserTarget;
5054

51-
const prodTarget = serveProd.browserTarget;
5255
if (prodTarget) {
5356
delete serveProd.browserTarget;
5457
serveProd.buildTarget = prodTarget;
5558
}
5659

57-
const serveDev = serve.configurations.development;
58-
const devTarget = serveDev.browserTarget;
60+
const serveDev = serve?.configurations?.development;
61+
const devTarget = serveDev?.browserTarget;
5962

6063
if (devTarget) {
6164
delete serveDev.browserTarget;

libs/native-federation-node/build/create-data-url.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ const dataUrl = `data:text/javascript;base64,${base64Content}`;
1313
const outputPath = path.resolve(__dirname, dataUrlFile);
1414
fs.writeFileSync(outputPath, `export const resolver = "${base64Content}";\n`);
1515

16-
console.log('Created data url for loader');
16+
console.log('Created data url for loader');

libs/native-federation-node/src/lib/node/federation-resolver.ts.bak

Lines changed: 0 additions & 57 deletions
This file was deleted.

libs/native-federation-node/src/lib/node/import-map-store.ts.bak

Lines changed: 0 additions & 11 deletions
This file was deleted.

libs/native-federation-node/src/lib/utils/import-map-loader.js

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
// https://raw.githubusercontent.com/node-loader/
44
//
55

6-
import path from "path";
7-
import url from "url";
8-
import { promises as fs } from "fs";
6+
import path from 'path';
7+
import url from 'url';
8+
import { promises as fs } from 'fs';
99

10-
export const IMPORT_MAP_FILE_NAME = "node.importmap";
10+
export const IMPORT_MAP_FILE_NAME = 'node.importmap';
1111

1212
const baseURL = url.pathToFileURL(process.cwd()) + path.sep;
1313

@@ -25,7 +25,7 @@ export function resolveSpecifier(importMap, specifier, parentURL) {
2525
for (let scopePrefix in importMap.scopes) {
2626
if (
2727
scopePrefix === currentBaseURL ||
28-
(scopePrefix.endsWith("/") && currentBaseURL.startsWith(scopePrefix))
28+
(scopePrefix.endsWith('/') && currentBaseURL.startsWith(scopePrefix))
2929
) {
3030
const scopeImportsMatch = resolveImportsMatch(
3131
normalizedSpecifier,
@@ -61,7 +61,7 @@ function resolveImportsMatch(normalizedSpecifier, specifierMap) {
6161
}
6262
return resolutionResult;
6363
} else if (
64-
specifierKey.endsWith("/") &&
64+
specifierKey.endsWith('/') &&
6565
normalizedSpecifier.startsWith(specifierKey)
6666
) {
6767
if (resolutionResult === null) {
@@ -94,7 +94,7 @@ export function resolveAndComposeImportMap(parsed) {
9494
let sortedAndNormalizedImports = {};
9595

9696
// Step 4
97-
if (parsed.hasOwnProperty("imports")) {
97+
if (parsed.hasOwnProperty('imports')) {
9898
// Step 4.1
9999
if (!isPlainObject(parsed.imports)) {
100100
throw Error(`Invalid import map - "imports" property must be an object`);
@@ -111,7 +111,7 @@ export function resolveAndComposeImportMap(parsed) {
111111
let sortedAndNormalizedScopes = {};
112112

113113
// Step 6
114-
if (parsed.hasOwnProperty("scopes")) {
114+
if (parsed.hasOwnProperty('scopes')) {
115115
// Step 6.1
116116
if (!isPlainObject(parsed.scopes)) {
117117
throw Error(`Invalid import map - "scopes" property must be an object`);
@@ -123,13 +123,13 @@ export function resolveAndComposeImportMap(parsed) {
123123

124124
// Step 7
125125
const invalidKeys = Object.keys(parsed).filter(
126-
(key) => key !== "imports" && key !== "scopes"
126+
(key) => key !== 'imports' && key !== 'scopes'
127127
);
128128
if (invalidKeys.length > 0) {
129129
console.warn(
130130
`Invalid top-level key${
131-
invalidKeys.length > 0 ? "s" : ""
132-
} in import map - ${invalidKeys.join(", ")}`
131+
invalidKeys.length > 0 ? 's' : ''
132+
} in import map - ${invalidKeys.join(', ')}`
133133
);
134134
}
135135

@@ -161,7 +161,7 @@ function sortAndNormalizeSpecifierMap(map, baseURL) {
161161
continue;
162162
}
163163

164-
if (specifierKey.endsWith("/") && !addressURL.endsWith("/")) {
164+
if (specifierKey.endsWith('/') && !addressURL.endsWith('/')) {
165165
console.warn(
166166
`Invalid URL address for import map specifier '${specifierKey}' - since the specifier ends in slash, so must the address`
167167
);
@@ -177,7 +177,7 @@ function sortAndNormalizeSpecifierMap(map, baseURL) {
177177

178178
// https://wicg.github.io/import-maps/#normalize-a-specifier-key
179179
function normalizeSpecifierKey(key) {
180-
if (key === "") {
180+
if (key === '') {
181181
console.warn(`Specifier keys in import maps may not be the empty string`);
182182
return null;
183183
}
@@ -188,9 +188,9 @@ function normalizeSpecifierKey(key) {
188188
// https://wicg.github.io/import-maps/#parse-a-url-like-import-specifier
189189
function parseURLLikeSpecifier(specifier, baseURL) {
190190
const useBaseUrlAsParent =
191-
specifier.startsWith("/") ||
192-
specifier.startsWith("./") ||
193-
specifier.startsWith("../");
191+
specifier.startsWith('/') ||
192+
specifier.startsWith('./') ||
193+
specifier.startsWith('../');
194194

195195
try {
196196
return new URL(specifier, useBaseUrlAsParent ? baseURL : undefined).href;
@@ -236,21 +236,23 @@ function isPlainObject(obj) {
236236

237237
// ---
238238

239-
240239
let importMapPromise = getImportMapPromise();
241240

242241
export async function resolve(specifier, context, defaultResolve) {
243242
const { parentURL = null } = context;
244243
const importMap = await importMapPromise;
245244
let importMapUrl = resolveSpecifier(importMap, specifier, parentURL);
246245

247-
if (importMapUrl?.startsWith('http://') || importMapUrl?.startsWith('https://')) {
246+
if (
247+
importMapUrl?.startsWith('http://') ||
248+
importMapUrl?.startsWith('https://')
249+
) {
248250
importMapUrl = await cacheBundle(importMapUrl);
249251
}
250252

251253
const r = defaultResolve(importMapUrl ?? specifier, context, defaultResolve);
252254

253-
return r.then(r => {
255+
return r.then((r) => {
254256
return { ...r, format: 'module' };
255257
});
256258
}
@@ -259,7 +261,7 @@ async function cacheBundle(importMapUrl) {
259261
const fileName = importMapUrl.replace(/[^a-zA-Z0-9.]/g, '_');
260262
const filePath = path.join('./cache', fileName);
261263

262-
if (!await exists(filePath)) {
264+
if (!(await exists(filePath))) {
263265
const res = await fetch(importMapUrl);
264266
const source = await res.text();
265267
await ensureCacheFolder();
@@ -271,7 +273,7 @@ async function cacheBundle(importMapUrl) {
271273
}
272274

273275
async function ensureCacheFolder() {
274-
if (!await exists('./cache')) {
276+
if (!(await exists('./cache'))) {
275277
await fs.mkdir('./cache');
276278
}
277279
}
@@ -321,7 +323,6 @@ function emptyMap() {
321323
return { imports: {}, scopes: {} };
322324
}
323325

324-
325326
async function exists(path) {
326327
try {
327328
await fs.access(path);

0 commit comments

Comments
 (0)