@angular/build 20.1.0 → 20.1.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/package.json +3 -3
- package/src/builders/application/build-action.js +2 -1
- package/src/builders/dev-server/vite-server.js +8 -0
- package/src/builders/karma/find-tests.js +4 -4
- package/src/builders/unit-test/builder.js +5 -5
- package/src/private.d.ts +9 -0
- package/src/private.js +2 -1
- package/src/tools/angular/compilation/factory.d.ts +1 -1
- package/src/tools/angular/compilation/factory.js +2 -2
- package/src/tools/esbuild/application-code-bundle.js +3 -7
- package/src/tools/esbuild/global-styles.js +2 -1
- package/src/tools/sass/rebasing-importer.js +2 -1
- package/src/utils/normalize-cache.js +1 -1
- package/src/utils/path.d.ts +29 -0
- package/src/utils/path.js +37 -0
- package/src/utils/server-rendering/prerender.js +2 -1
- package/src/utils/service-worker.js +4 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/build",
|
|
3
|
-
"version": "20.1.
|
|
3
|
+
"version": "20.1.1",
|
|
4
4
|
"description": "Official build system for Angular",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Angular CLI",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"builders": "builders.json",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@ampproject/remapping": "2.3.0",
|
|
26
|
-
"@angular-devkit/architect": "0.2001.
|
|
26
|
+
"@angular-devkit/architect": "0.2001.1",
|
|
27
27
|
"@babel/core": "7.27.7",
|
|
28
28
|
"@babel/helper-annotate-as-pure": "7.27.3",
|
|
29
29
|
"@babel/helper-split-export-declaration": "7.24.7",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@angular/platform-browser": "^20.0.0",
|
|
61
61
|
"@angular/platform-server": "^20.0.0",
|
|
62
62
|
"@angular/service-worker": "^20.0.0",
|
|
63
|
-
"@angular/ssr": "^20.1.
|
|
63
|
+
"@angular/ssr": "^20.1.1",
|
|
64
64
|
"karma": "^6.4.0",
|
|
65
65
|
"less": "^4.2.0",
|
|
66
66
|
"ng-packagr": "^20.0.0",
|
|
@@ -50,6 +50,7 @@ const bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
|
|
50
50
|
const sass_language_1 = require("../../tools/esbuild/stylesheets/sass-language");
|
|
51
51
|
const utils_1 = require("../../tools/esbuild/utils");
|
|
52
52
|
const environment_options_1 = require("../../utils/environment-options");
|
|
53
|
+
const path_1 = require("../../utils/path");
|
|
53
54
|
const results_1 = require("./results");
|
|
54
55
|
// Watch workspace for package manager changes
|
|
55
56
|
const packageWatchFiles = [
|
|
@@ -91,7 +92,7 @@ async function* runEsBuildBuildAction(action, options) {
|
|
|
91
92
|
// Ignore the output and cache paths to avoid infinite rebuild cycles
|
|
92
93
|
outputOptions.base,
|
|
93
94
|
cacheOptions.basePath,
|
|
94
|
-
`${
|
|
95
|
+
`${(0, path_1.toPosixPath)(workspaceRoot)}/**/.*/**`,
|
|
95
96
|
];
|
|
96
97
|
// Setup a watcher
|
|
97
98
|
const { createWatcher } = await Promise.resolve().then(() => __importStar(require('../../tools/esbuild/watcher')));
|
|
@@ -55,6 +55,7 @@ const utils_2 = require("../../utils");
|
|
|
55
55
|
const environment_options_1 = require("../../utils/environment-options");
|
|
56
56
|
const load_esm_1 = require("../../utils/load-esm");
|
|
57
57
|
const results_1 = require("../application/results");
|
|
58
|
+
const schema_1 = require("../application/schema");
|
|
58
59
|
const internal_1 = require("./internal");
|
|
59
60
|
/**
|
|
60
61
|
* Build options that are also present on the dev server but are only passed
|
|
@@ -114,6 +115,13 @@ async function* serveWithVite(serverOptions, builderName, builderAction, context
|
|
|
114
115
|
// https://nodejs.org/api/process.html#processsetsourcemapsenabledval
|
|
115
116
|
process.setSourceMapsEnabled(true);
|
|
116
117
|
}
|
|
118
|
+
if (serverOptions.hmr &&
|
|
119
|
+
(browserOptions.outputHashing === schema_1.OutputHashing.All ||
|
|
120
|
+
browserOptions.outputHashing === schema_1.OutputHashing.Bundles)) {
|
|
121
|
+
serverOptions.hmr = false;
|
|
122
|
+
context.logger.warn(`Hot Module Replacement (HMR) is disabled because the 'outputHashing' option is set to '${browserOptions.outputHashing}'. ` +
|
|
123
|
+
'HMR is incompatible with this setting.');
|
|
124
|
+
}
|
|
117
125
|
const componentsHmrCanBeUsed = browserOptions.aot && serverOptions.liveReload && serverOptions.hmr;
|
|
118
126
|
// Enable to support link-based component style hot reloading (`NG_HMR_CSTYLES=1` can be used to enable)
|
|
119
127
|
browserOptions.externalRuntimeStyles = componentsHmrCanBeUsed && environment_options_1.useComponentStyleHmr;
|
|
@@ -12,6 +12,7 @@ exports.getTestEntrypoints = getTestEntrypoints;
|
|
|
12
12
|
const node_fs_1 = require("node:fs");
|
|
13
13
|
const node_path_1 = require("node:path");
|
|
14
14
|
const tinyglobby_1 = require("tinyglobby");
|
|
15
|
+
const path_1 = require("../../utils/path");
|
|
15
16
|
/* Go through all patterns and find unique list of files */
|
|
16
17
|
async function findTests(include, exclude, workspaceRoot, projectSourceRoot) {
|
|
17
18
|
const matchingTestsPromises = include.map((pattern) => findMatchingTests(pattern, exclude, workspaceRoot, projectSourceRoot));
|
|
@@ -39,7 +40,6 @@ function getTestEntrypoints(testFiles, { projectSourceRoot, workspaceRoot }) {
|
|
|
39
40
|
return [uniqueName, testFile];
|
|
40
41
|
}));
|
|
41
42
|
}
|
|
42
|
-
const normalizePath = (path) => path.replace(/\\/g, '/');
|
|
43
43
|
const removeLeadingSlash = (pattern) => {
|
|
44
44
|
if (pattern.charAt(0) === '/') {
|
|
45
45
|
return pattern.substring(1);
|
|
@@ -62,9 +62,9 @@ function removeRoots(path, roots) {
|
|
|
62
62
|
}
|
|
63
63
|
async function findMatchingTests(pattern, ignore, workspaceRoot, projectSourceRoot) {
|
|
64
64
|
// normalize pattern, glob lib only accepts forward slashes
|
|
65
|
-
let normalizedPattern =
|
|
65
|
+
let normalizedPattern = (0, path_1.toPosixPath)(pattern);
|
|
66
66
|
normalizedPattern = removeLeadingSlash(normalizedPattern);
|
|
67
|
-
const relativeProjectRoot =
|
|
67
|
+
const relativeProjectRoot = (0, path_1.toPosixPath)((0, node_path_1.relative)(workspaceRoot, projectSourceRoot) + '/');
|
|
68
68
|
// remove relativeProjectRoot to support relative paths from root
|
|
69
69
|
// such paths are easy to get when running scripts via IDEs
|
|
70
70
|
normalizedPattern = removeRelativeRoot(normalizedPattern, relativeProjectRoot);
|
|
@@ -84,7 +84,7 @@ async function findMatchingTests(pattern, ignore, workspaceRoot, projectSourceRo
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
// normalize the patterns in the ignore list
|
|
87
|
-
const normalizedIgnorePatternList = ignore.map((pattern) => removeRelativeRoot(removeLeadingSlash(
|
|
87
|
+
const normalizedIgnorePatternList = ignore.map((pattern) => removeRelativeRoot(removeLeadingSlash((0, path_1.toPosixPath)(pattern)), relativeProjectRoot));
|
|
88
88
|
return (0, tinyglobby_1.glob)(normalizedPattern, {
|
|
89
89
|
cwd: projectSourceRoot,
|
|
90
90
|
absolute: true,
|
|
@@ -18,6 +18,7 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
18
18
|
const virtual_module_plugin_1 = require("../../tools/esbuild/virtual-module-plugin");
|
|
19
19
|
const error_1 = require("../../utils/error");
|
|
20
20
|
const load_esm_1 = require("../../utils/load-esm");
|
|
21
|
+
const path_1 = require("../../utils/path");
|
|
21
22
|
const application_1 = require("../application");
|
|
22
23
|
const results_1 = require("../application/results");
|
|
23
24
|
const schema_1 = require("../application/schema");
|
|
@@ -73,7 +74,7 @@ async function* execute(options, context, extensions = {}) {
|
|
|
73
74
|
// Setup test file build options based on application build target options
|
|
74
75
|
const buildTargetOptions = (await context.validateOptions(await context.getTargetOptions(normalizedOptions.buildTarget), await context.getBuilderNameForTarget(normalizedOptions.buildTarget)));
|
|
75
76
|
buildTargetOptions.polyfills = (0, options_1.injectTestingPolyfills)(buildTargetOptions.polyfills);
|
|
76
|
-
const outputPath = node_path_1.default.join(context.workspaceRoot, generateOutputPath());
|
|
77
|
+
const outputPath = (0, path_1.toPosixPath)(node_path_1.default.join(context.workspaceRoot, generateOutputPath()));
|
|
77
78
|
const buildOptions = {
|
|
78
79
|
...buildTargetOptions,
|
|
79
80
|
watch: normalizedOptions.watch,
|
|
@@ -112,10 +113,9 @@ async function* execute(options, context, extensions = {}) {
|
|
|
112
113
|
`import { BrowserTestingModule, platformBrowserTesting } from '@angular/platform-browser/testing';`,
|
|
113
114
|
'',
|
|
114
115
|
normalizedOptions.providersFile
|
|
115
|
-
? `import providers from './${node_path_1.default
|
|
116
|
+
? `import providers from './${(0, path_1.toPosixPath)(node_path_1.default
|
|
116
117
|
.relative(projectSourceRoot, normalizedOptions.providersFile)
|
|
117
|
-
.replace(/.[mc]?ts$/, '')
|
|
118
|
-
.replace(/\\/g, '/')}'`
|
|
118
|
+
.replace(/.[mc]?ts$/, ''))}'`
|
|
119
119
|
: 'const providers = [];',
|
|
120
120
|
'',
|
|
121
121
|
// Same as https://github.com/angular/angular/blob/05a03d3f975771bb59c7eefd37c01fa127ee2229/packages/core/testing/src/test_hooks.ts#L21-L29
|
|
@@ -308,7 +308,7 @@ function generateCoverageOption(codeCoverage, workspaceRoot, outputPath) {
|
|
|
308
308
|
return {
|
|
309
309
|
enabled: true,
|
|
310
310
|
excludeAfterRemap: true,
|
|
311
|
-
include: [`${node_path_1.default.relative(workspaceRoot, outputPath)}/**`],
|
|
311
|
+
include: [`${(0, path_1.toPosixPath)(node_path_1.default.relative(workspaceRoot, outputPath))}/**`],
|
|
312
312
|
// Special handling for `reporter` due to an undefined value causing upstream failures
|
|
313
313
|
...(codeCoverage.reporters
|
|
314
314
|
? { reporter: codeCoverage.reporters }
|
package/src/private.d.ts
CHANGED
|
@@ -5,6 +5,13 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.dev/license
|
|
7
7
|
*/
|
|
8
|
+
/**
|
|
9
|
+
* @fileoverview
|
|
10
|
+
* Private exports intended only for use with the @angular-devkit/build-angular package.
|
|
11
|
+
* All exports are not supported for external use, do not provide SemVer guarantees, and
|
|
12
|
+
* their existence may change in any future version.
|
|
13
|
+
*/
|
|
14
|
+
import { createAngularCompilation } from './tools/angular/compilation';
|
|
8
15
|
import { CompilerPluginOptions } from './tools/esbuild/angular/compiler-plugin';
|
|
9
16
|
import { BundleStylesheetOptions } from './tools/esbuild/stylesheets/bundle-options';
|
|
10
17
|
export { buildApplicationInternal } from './builders/application';
|
|
@@ -25,6 +32,8 @@ export declare function createCompilerPlugin(pluginOptions: CompilerPluginOption
|
|
|
25
32
|
}, styleOptions: BundleStylesheetOptions & {
|
|
26
33
|
inlineStyleLanguage: string;
|
|
27
34
|
}): import('esbuild').Plugin;
|
|
35
|
+
export type { AngularCompilation } from './tools/angular/compilation';
|
|
36
|
+
export { createAngularCompilation };
|
|
28
37
|
export * from './utils/bundle-calculator';
|
|
29
38
|
export { checkPort } from './utils/check-port';
|
|
30
39
|
export { deleteOutputDir } from './utils/delete-output-dir';
|
package/src/private.js
CHANGED
|
@@ -21,7 +21,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
21
21
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
22
|
};
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.loadPostcssConfiguration = exports.generateSearchDirectories = exports.findTailwindConfiguration = exports.getTestEntrypoints = exports.findTests = exports.assertCompatibleAngularVersion = exports.getSupportedBrowsers = exports.generateBuildStatsTable = exports.augmentAppWithServiceWorker = exports.purgeStaleBuildCache = exports.createTranslationLoader = exports.loadProxyConfiguration = exports.InlineCriticalCssProcessor = exports.IndexHtmlGenerator = exports.loadTranslations = exports.createI18nOptions = exports.deleteOutputDir = exports.checkPort = exports.JavaScriptTransformer = exports.createJitResourceTransformer = exports.SourceFileCache = exports.SassWorkerImplementation = exports.transformSupportedBrowsersToTargets = exports.emitFilesToDisk = exports.serveWithVite = exports.ResultKind = exports.buildApplicationInternal = void 0;
|
|
24
|
+
exports.loadPostcssConfiguration = exports.generateSearchDirectories = exports.findTailwindConfiguration = exports.getTestEntrypoints = exports.findTests = exports.assertCompatibleAngularVersion = exports.getSupportedBrowsers = exports.generateBuildStatsTable = exports.augmentAppWithServiceWorker = exports.purgeStaleBuildCache = exports.createTranslationLoader = exports.loadProxyConfiguration = exports.InlineCriticalCssProcessor = exports.IndexHtmlGenerator = exports.loadTranslations = exports.createI18nOptions = exports.deleteOutputDir = exports.checkPort = exports.createAngularCompilation = exports.JavaScriptTransformer = exports.createJitResourceTransformer = exports.SourceFileCache = exports.SassWorkerImplementation = exports.transformSupportedBrowsersToTargets = exports.emitFilesToDisk = exports.serveWithVite = exports.ResultKind = exports.buildApplicationInternal = void 0;
|
|
25
25
|
exports.createCompilerPlugin = createCompilerPlugin;
|
|
26
26
|
/**
|
|
27
27
|
* @fileoverview
|
|
@@ -30,6 +30,7 @@ exports.createCompilerPlugin = createCompilerPlugin;
|
|
|
30
30
|
* their existence may change in any future version.
|
|
31
31
|
*/
|
|
32
32
|
const compilation_1 = require("./tools/angular/compilation");
|
|
33
|
+
Object.defineProperty(exports, "createAngularCompilation", { enumerable: true, get: function () { return compilation_1.createAngularCompilation; } });
|
|
33
34
|
const compiler_plugin_1 = require("./tools/esbuild/angular/compiler-plugin");
|
|
34
35
|
const component_stylesheets_1 = require("./tools/esbuild/angular/component-stylesheets");
|
|
35
36
|
// Builders
|
|
@@ -14,4 +14,4 @@ import type { AngularCompilation } from './angular-compilation';
|
|
|
14
14
|
* @param browserOnlyBuild True, for browser only builds; False, for browser and server builds.
|
|
15
15
|
* @returns An instance of an Angular compilation object.
|
|
16
16
|
*/
|
|
17
|
-
export declare function createAngularCompilation(jit: boolean, browserOnlyBuild: boolean): Promise<AngularCompilation>;
|
|
17
|
+
export declare function createAngularCompilation(jit: boolean, browserOnlyBuild: boolean, parallel?: boolean): Promise<AngularCompilation>;
|
|
@@ -50,8 +50,8 @@ const environment_options_1 = require("../../../utils/environment-options");
|
|
|
50
50
|
* @param browserOnlyBuild True, for browser only builds; False, for browser and server builds.
|
|
51
51
|
* @returns An instance of an Angular compilation object.
|
|
52
52
|
*/
|
|
53
|
-
async function createAngularCompilation(jit, browserOnlyBuild) {
|
|
54
|
-
if (
|
|
53
|
+
async function createAngularCompilation(jit, browserOnlyBuild, parallel = environment_options_1.useParallelTs) {
|
|
54
|
+
if (parallel) {
|
|
55
55
|
const { ParallelCompilation } = await Promise.resolve().then(() => __importStar(require('./parallel-compilation')));
|
|
56
56
|
return new ParallelCompilation(jit, browserOnlyBuild);
|
|
57
57
|
}
|
|
@@ -20,6 +20,7 @@ const node_crypto_1 = require("node:crypto");
|
|
|
20
20
|
const node_path_1 = require("node:path");
|
|
21
21
|
const schema_1 = require("../../builders/application/schema");
|
|
22
22
|
const environment_options_1 = require("../../utils/environment-options");
|
|
23
|
+
const path_1 = require("../../utils/path");
|
|
23
24
|
const manifest_1 = require("../../utils/server-rendering/manifest");
|
|
24
25
|
const compilation_1 = require("../angular/compilation");
|
|
25
26
|
const compiler_plugin_1 = require("./angular/compiler-plugin");
|
|
@@ -511,9 +512,7 @@ function getEsBuildCommonPolyfillsOptions(options, namespace, tryToResolvePolyfi
|
|
|
511
512
|
}));
|
|
512
513
|
}
|
|
513
514
|
// Generate module contents with an import statement per defined polyfill
|
|
514
|
-
let contents = polyfillPaths
|
|
515
|
-
.map((file) => `import '${file.replace(/\\/g, '/')}';`)
|
|
516
|
-
.join('\n');
|
|
515
|
+
let contents = polyfillPaths.map((file) => `import '${(0, path_1.toPosixPath)(file)}';`).join('\n');
|
|
517
516
|
// The below should be done after loading `$localize` as otherwise the locale will be overridden.
|
|
518
517
|
if (i18nOptions.shouldInline) {
|
|
519
518
|
// When inlining, a placeholder is used to allow the post-processing step to inject the $localize locale identifier.
|
|
@@ -534,8 +533,5 @@ function getEsBuildCommonPolyfillsOptions(options, namespace, tryToResolvePolyfi
|
|
|
534
533
|
return buildOptions;
|
|
535
534
|
}
|
|
536
535
|
function entryFileToWorkspaceRelative(workspaceRoot, entryFile) {
|
|
537
|
-
return
|
|
538
|
-
(0, node_path_1.relative)(workspaceRoot, entryFile)
|
|
539
|
-
.replace(/.[mc]?ts$/, '')
|
|
540
|
-
.replace(/\\/g, '/'));
|
|
536
|
+
return './' + (0, path_1.toPosixPath)((0, node_path_1.relative)(workspaceRoot, entryFile).replace(/.[mc]?ts$/, ''));
|
|
541
537
|
}
|
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.createGlobalStylesBundleOptions = createGlobalStylesBundleOptions;
|
|
14
14
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
15
|
+
const path_1 = require("../../utils/path");
|
|
15
16
|
const bundle_options_1 = require("./stylesheets/bundle-options");
|
|
16
17
|
const virtual_module_plugin_1 = require("./virtual-module-plugin");
|
|
17
18
|
function createGlobalStylesBundleOptions(options, target, initial) {
|
|
@@ -66,7 +67,7 @@ function createGlobalStylesBundleOptions(options, target, initial) {
|
|
|
66
67
|
const files = globalStyles.find(({ name }) => name === args.path)?.files;
|
|
67
68
|
(0, node_assert_1.default)(files, `global style name should always be found [${args.path}]`);
|
|
68
69
|
return {
|
|
69
|
-
contents: files.map((file) => `@import '${
|
|
70
|
+
contents: files.map((file) => `@import '${(0, path_1.toPosixPath)(file)}';`).join('\n'),
|
|
70
71
|
loader: 'css',
|
|
71
72
|
resolveDir: workspaceRoot,
|
|
72
73
|
};
|
|
@@ -17,6 +17,7 @@ const node_fs_1 = require("node:fs");
|
|
|
17
17
|
const node_path_1 = require("node:path");
|
|
18
18
|
const node_url_1 = require("node:url");
|
|
19
19
|
const error_1 = require("../../utils/error");
|
|
20
|
+
const path_1 = require("../../utils/path");
|
|
20
21
|
const lexer_1 = require("./lexer");
|
|
21
22
|
/**
|
|
22
23
|
* A Sass Importer base class that provides the load logic to rebase all `url()` functions
|
|
@@ -69,7 +70,7 @@ class UrlRebasingImporter {
|
|
|
69
70
|
const rebasedPath = (0, node_path_1.relative)(this.entryDirectory, stylesheetDirectory);
|
|
70
71
|
// Normalize path separators and escape characters
|
|
71
72
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/url#syntax
|
|
72
|
-
const rebasedUrl =
|
|
73
|
+
const rebasedUrl = (0, path_1.toPosixPath)(rebasedPath).replace(/[()\s'"]/g, '\\$&');
|
|
73
74
|
updatedContents ??= new magic_string_1.default(contents);
|
|
74
75
|
// Always quote the URL to avoid potential downstream parsing problems
|
|
75
76
|
updatedContents.update(start, end, `"${rebasedUrl}||file:${valueNormalized}"`);
|
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.normalizeCacheOptions = normalizeCacheOptions;
|
|
11
11
|
const node_path_1 = require("node:path");
|
|
12
12
|
/** Version placeholder is replaced during the build process with actual package version */
|
|
13
|
-
const VERSION = '20.1.
|
|
13
|
+
const VERSION = '20.1.1';
|
|
14
14
|
function hasCacheMetadata(value) {
|
|
15
15
|
return (!!value &&
|
|
16
16
|
typeof value === 'object' &&
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Converts a Windows-style file path to a POSIX-compliant path.
|
|
10
|
+
*
|
|
11
|
+
* This function replaces all backslashes (`\`) with forward slashes (`/`).
|
|
12
|
+
* It is a no-op on POSIX systems (e.g., Linux, macOS), as the conversion
|
|
13
|
+
* only runs on Windows (`win32`).
|
|
14
|
+
*
|
|
15
|
+
* @param path - The file path to convert.
|
|
16
|
+
* @returns The POSIX-compliant file path.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* // On a Windows system:
|
|
21
|
+
* toPosixPath('C:\\Users\\Test\\file.txt');
|
|
22
|
+
* // => 'C:/Users/Test/file.txt'
|
|
23
|
+
*
|
|
24
|
+
* // On a POSIX system (Linux/macOS):
|
|
25
|
+
* toPosixPath('/home/user/file.txt');
|
|
26
|
+
* // => '/home/user/file.txt'
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function toPosixPath(path: string): string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.toPosixPath = toPosixPath;
|
|
11
|
+
const node_path_1 = require("node:path");
|
|
12
|
+
const node_process_1 = require("node:process");
|
|
13
|
+
const WINDOWS_PATH_SEPERATOR_REGEXP = /\\/g;
|
|
14
|
+
/**
|
|
15
|
+
* Converts a Windows-style file path to a POSIX-compliant path.
|
|
16
|
+
*
|
|
17
|
+
* This function replaces all backslashes (`\`) with forward slashes (`/`).
|
|
18
|
+
* It is a no-op on POSIX systems (e.g., Linux, macOS), as the conversion
|
|
19
|
+
* only runs on Windows (`win32`).
|
|
20
|
+
*
|
|
21
|
+
* @param path - The file path to convert.
|
|
22
|
+
* @returns The POSIX-compliant file path.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* // On a Windows system:
|
|
27
|
+
* toPosixPath('C:\\Users\\Test\\file.txt');
|
|
28
|
+
* // => 'C:/Users/Test/file.txt'
|
|
29
|
+
*
|
|
30
|
+
* // On a POSIX system (Linux/macOS):
|
|
31
|
+
* toPosixPath('/home/user/file.txt');
|
|
32
|
+
* // => '/home/user/file.txt'
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
function toPosixPath(path) {
|
|
36
|
+
return node_process_1.platform === 'win32' ? path.replace(WINDOWS_PATH_SEPERATOR_REGEXP, node_path_1.posix.sep) : path;
|
|
37
|
+
}
|
|
@@ -13,6 +13,7 @@ const node_path_1 = require("node:path");
|
|
|
13
13
|
const schema_1 = require("../../builders/application/schema");
|
|
14
14
|
const bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
|
15
15
|
const error_1 = require("../error");
|
|
16
|
+
const path_1 = require("../path");
|
|
16
17
|
const url_1 = require("../url");
|
|
17
18
|
const worker_pool_1 = require("../worker-pool");
|
|
18
19
|
const utils_1 = require("./esm-in-memory-loader/utils");
|
|
@@ -49,7 +50,7 @@ async function prerenderPages(workspaceRoot, baseHref, appShellOptions, prerende
|
|
|
49
50
|
serverBundlesSourceMaps.clear();
|
|
50
51
|
const assetsReversed = {};
|
|
51
52
|
for (const { source, destination } of assets) {
|
|
52
|
-
assetsReversed[addLeadingSlash(
|
|
53
|
+
assetsReversed[addLeadingSlash((0, path_1.toPosixPath)(destination))] = source;
|
|
53
54
|
}
|
|
54
55
|
// Get routes to prerender
|
|
55
56
|
const { errors: extractionErrors, serializedRouteTree: serializableRouteTreeNode, appShellRoute, } = await getAllRoutes(workspaceRoot, baseHref, outputFilesForWorker, assetsReversed, appShellOptions, prerenderOptions, sourcemap, outputMode).catch((err) => {
|
|
@@ -49,6 +49,7 @@ const path = __importStar(require("node:path"));
|
|
|
49
49
|
const bundler_context_1 = require("../tools/esbuild/bundler-context");
|
|
50
50
|
const error_1 = require("./error");
|
|
51
51
|
const load_esm_1 = require("./load-esm");
|
|
52
|
+
const path_1 = require("./path");
|
|
52
53
|
class CliFilesystem {
|
|
53
54
|
fs;
|
|
54
55
|
base;
|
|
@@ -81,7 +82,7 @@ class CliFilesystem {
|
|
|
81
82
|
const stats = await this.fs.stat(entryPath);
|
|
82
83
|
if (stats.isFile()) {
|
|
83
84
|
// Uses posix paths since the service worker expects URLs
|
|
84
|
-
items.push('/' + path.relative(this.base, entryPath)
|
|
85
|
+
items.push('/' + (0, path_1.toPosixPath)(path.relative(this.base, entryPath)));
|
|
85
86
|
}
|
|
86
87
|
else if (stats.isDirectory()) {
|
|
87
88
|
subdirectories.push(entryPath);
|
|
@@ -98,11 +99,11 @@ class ResultFilesystem {
|
|
|
98
99
|
constructor(outputFiles, assetFiles) {
|
|
99
100
|
for (const file of outputFiles) {
|
|
100
101
|
if (file.type === bundler_context_1.BuildOutputFileType.Media || file.type === bundler_context_1.BuildOutputFileType.Browser) {
|
|
101
|
-
this.fileReaders.set('/' +
|
|
102
|
+
this.fileReaders.set('/' + (0, path_1.toPosixPath)(file.path), async () => file.contents);
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
for (const file of assetFiles) {
|
|
105
|
-
this.fileReaders.set('/' +
|
|
106
|
+
this.fileReaders.set('/' + (0, path_1.toPosixPath)(file.destination), () => node_fs_1.promises.readFile(file.source));
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
async list(dir) {
|