Skip to content

Commit 0d4dc0a

Browse files
author
Angular Builds
committed
650aeec build: add missing pkg_deps for @angular/create
1 parent 76b173c commit 0d4dc0a

File tree

10 files changed

+45
-30
lines changed

10 files changed

+45
-30
lines changed

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"name": "@angular-devkit/build-angular",
3-
"version": "18.3.0-next.0+sha-dcbdb8b",
3+
"version": "18.3.0-next.0+sha-650aeec",
44
"description": "Angular Webpack Build Facade",
55
"main": "src/index.js",
66
"typings": "src/index.d.ts",
77
"builders": "builders.json",
88
"dependencies": {
99
"@ampproject/remapping": "2.3.0",
10-
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#dcbdb8b",
11-
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#dcbdb8b",
12-
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#dcbdb8b",
13-
"@angular/build": "github:angular/angular-build-builds#dcbdb8b",
10+
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#650aeec",
11+
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#650aeec",
12+
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#650aeec",
13+
"@angular/build": "github:angular/angular-build-builds#650aeec",
1414
"@babel/core": "7.25.2",
1515
"@babel/generator": "7.25.0",
1616
"@babel/helper-annotate-as-pure": "7.24.7",
@@ -21,7 +21,7 @@
2121
"@babel/preset-env": "7.25.3",
2222
"@babel/runtime": "7.25.0",
2323
"@discoveryjs/json-ext": "0.6.1",
24-
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#dcbdb8b",
24+
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#650aeec",
2525
"@vitejs/plugin-basic-ssl": "1.1.0",
2626
"ansi-colors": "4.1.3",
2727
"autoprefixer": "10.4.20",
@@ -77,6 +77,7 @@
7777
"@angular/localize": "^18.0.0 || ^18.2.0-next.0",
7878
"@angular/platform-server": "^18.0.0 || ^18.2.0-next.0",
7979
"@angular/service-worker": "^18.0.0 || ^18.2.0-next.0",
80+
"@angular/ssr": "github:angular/angular-ssr-builds#650aeec",
8081
"@web/test-runner": "^0.18.0",
8182
"browser-sync": "^3.0.2",
8283
"jest": "^29.5.0",
@@ -97,6 +98,7 @@
9798
"@angular/service-worker": {
9899
"optional": true
99100
},
101+
"@angular/ssr": "github:angular/angular-ssr-builds#650aeec",
100102
"@web/test-runner": {
101103
"optional": true
102104
},

src/builders/prerender/routes-extractor-worker.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ const path = __importStar(require("node:path"));
3939
const node_worker_threads_1 = require("node:worker_threads");
4040
const { zonePackage, serverBundlePath, outputPath, indexFile } = node_worker_threads_1.workerData;
4141
async function extract() {
42-
const { AppServerModule, extractRoutes, default: bootstrapAppFn, } = (await Promise.resolve(`${serverBundlePath}`).then(s => __importStar(require(s))));
42+
const { AppServerModule, ɵgetRoutesFromAngularRouterConfig: getRoutesFromAngularRouterConfig, default: bootstrapAppFn, } = (await Promise.resolve(`${serverBundlePath}`).then(s => __importStar(require(s))));
4343
const browserIndexInputPath = path.join(outputPath, indexFile);
4444
const document = await fs.promises.readFile(browserIndexInputPath, 'utf8');
4545
const bootstrapAppFnOrModule = bootstrapAppFn || AppServerModule;
4646
(0, node_assert_1.default)(bootstrapAppFnOrModule, `The file "${serverBundlePath}" does not have a default export for an AppServerModule or a bootstrapping function.`);
4747
const routes = [];
48-
for await (const { route, success } of extractRoutes(bootstrapAppFnOrModule, document)) {
49-
if (success) {
48+
const { routes: extractRoutes } = await getRoutesFromAngularRouterConfig(bootstrapAppFnOrModule, document, new URL('http://localhost'));
49+
for (const { route, redirectTo } of extractRoutes) {
50+
if (redirectTo === undefined && !/[:*]/.test(route)) {
5051
routes.push(route);
5152
}
5253
}

src/builders/server/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,16 @@ function getPlatformServerExportsConfig(wco) {
183183
// Only add `@angular/platform-server` exports when it is installed.
184184
// In some cases this builder is used when `@angular/platform-server` is not installed.
185185
// Example: when using `@nguniversal/common/clover` which does not need `@angular/platform-server`.
186-
return (0, helpers_1.isPlatformServerInstalled)(wco.root)
186+
return (0, helpers_1.isPackageInstalled)(wco.root, '@angular/platform-server')
187187
? {
188188
module: {
189189
rules: [
190190
{
191191
loader: require.resolve('./platform-server-exports-loader'),
192192
include: [path.resolve(wco.root, wco.buildOptions.main)],
193+
options: {
194+
angularSSRInstalled: (0, helpers_1.isPackageInstalled)(wco.root, '@angular/ssr'),
195+
},
193196
},
194197
],
195198
},

src/builders/server/platform-server-exports-loader.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@
1010
* allow exports from multiple files in the same entry.
1111
* @see https://github.com/webpack/webpack/issues/15936.
1212
*/
13-
export default function (this: import('webpack').LoaderContext<{}>, content: string, map: Parameters<import('webpack').LoaderDefinitionFunction>[1]): void;
13+
export default function (this: import('webpack').LoaderContext<{
14+
angularSSRInstalled: boolean;
15+
}>, content: string, map: Parameters<import('webpack').LoaderDefinitionFunction>[1]): void;

src/builders/server/platform-server-exports-loader.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@
88
*/
99
Object.defineProperty(exports, "__esModule", { value: true });
1010
exports.default = default_1;
11-
const node_fs_1 = require("node:fs");
12-
const node_path_1 = require("node:path");
1311
/**
1412
* This loader is needed to add additional exports and is a workaround for a Webpack bug that doesn't
1513
* allow exports from multiple files in the same entry.
1614
* @see https://github.com/webpack/webpack/issues/15936.
1715
*/
1816
function default_1(content, map) {
19-
const extractorPath = (0, node_path_1.join)((0, node_path_1.dirname)(require.resolve('@angular/build/package.json')), 'src/utils/routes-extractor/extractor.js');
20-
const source = `${content}
17+
const { angularSSRInstalled } = this.getOptions();
18+
let source = `${content}
2119
2220
// EXPORTS added by @angular-devkit/build-angular
2321
export { renderApplication, renderModule, ɵSERVER_CONTEXT } from '@angular/platform-server';
24-
` +
25-
// We do not import it directly so that node.js modules are resolved using the correct context.
26-
// Remove source map URL comments from the code if a sourcemap is present as this will not match the file.
27-
(0, node_fs_1.readFileSync)(extractorPath, 'utf-8').replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, '');
22+
`;
23+
if (angularSSRInstalled) {
24+
source += `
25+
export { ɵgetRoutesFromAngularRouterConfig } from '@angular/ssr';
26+
`;
27+
}
2828
this.callback(null, source, map);
2929
return;
3030
}

src/tools/webpack/configs/common.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ async function getCommonConfig(wco) {
8585
if (isPlatformServer) {
8686
// Fixes Critical dependency: the request of a dependency is an expression
8787
extraPlugins.push(new webpack_2.ContextReplacementPlugin(/@?hapi|express[\\/]/));
88-
if ((0, helpers_1.isPlatformServerInstalled)(wco.root) && Array.isArray(entryPoints['main'])) {
88+
if ((0, helpers_1.isPackageInstalled)(wco.root, '@angular/platform-server') &&
89+
Array.isArray(entryPoints['main'])) {
8990
// This import must come before any imports (direct or transitive) that rely on DOM built-ins being
9091
// available, such as `@angular/elements`.
9192
entryPoints['main'].unshift('@angular/platform-server/init');

src/tools/webpack/utils/helpers.d.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ export declare function globalScriptsByBundleName(scripts: ScriptElement[]): {
3434
export declare function assetPatterns(root: string, assets: AssetPatternClass[]): ObjectPattern[];
3535
export declare function getStatsOptions(verbose?: boolean): WebpackStatsOptions;
3636
/**
37-
* @param root the workspace root
38-
* @returns `true` when `@angular/platform-server` is installed.
37+
* Checks if a specified package is installed in the given workspace.
38+
*
39+
* @param root - The root directory of the workspace.
40+
* @param name - The name of the package to check for.
41+
* @returns `true` if the package is installed, `false` otherwise.
3942
*/
40-
export declare function isPlatformServerInstalled(root: string): boolean;
43+
export declare function isPackageInstalled(root: string, name: string): boolean;

src/tools/webpack/utils/helpers.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ exports.getCacheSettings = getCacheSettings;
4242
exports.globalScriptsByBundleName = globalScriptsByBundleName;
4343
exports.assetPatterns = assetPatterns;
4444
exports.getStatsOptions = getStatsOptions;
45-
exports.isPlatformServerInstalled = isPlatformServerInstalled;
45+
exports.isPackageInstalled = isPackageInstalled;
4646
const crypto_1 = require("crypto");
4747
const fast_glob_1 = __importDefault(require("fast-glob"));
4848
const path = __importStar(require("path"));
@@ -276,12 +276,15 @@ function getStatsOptions(verbose = false) {
276276
: webpackOutputOptions;
277277
}
278278
/**
279-
* @param root the workspace root
280-
* @returns `true` when `@angular/platform-server` is installed.
279+
* Checks if a specified package is installed in the given workspace.
280+
*
281+
* @param root - The root directory of the workspace.
282+
* @param name - The name of the package to check for.
283+
* @returns `true` if the package is installed, `false` otherwise.
281284
*/
282-
function isPlatformServerInstalled(root) {
285+
function isPackageInstalled(root, name) {
283286
try {
284-
require.resolve('@angular/platform-server', { paths: [root] });
287+
require.resolve(name, { paths: [root] });
285288
return true;
286289
}
287290
catch {

src/utils/normalize-cache.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
1010
exports.normalizeCacheOptions = normalizeCacheOptions;
1111
const node_path_1 = require("node:path");
1212
/** Version placeholder is replaced during the build process with actual package version */
13-
const VERSION = '18.3.0-next.0+sha-dcbdb8b';
13+
const VERSION = '18.3.0-next.0+sha-650aeec';
1414
function hasCacheMetadata(value) {
1515
return (!!value &&
1616
typeof value === 'object' &&

uniqueId

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Wed Aug 14 2024 14:26:45 GMT+0000 (Coordinated Universal Time)
1+
Wed Aug 14 2024 14:47:52 GMT+0000 (Coordinated Universal Time)

0 commit comments

Comments
 (0)