@nx/angular 17.3.0-rc.1 → 17.3.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/package.json +10 -10
- package/src/generators/setup-ssr/files/server/application-builder/__serverFileName__ +1 -1
- package/src/generators/setup-ssr/lib/add-server-file.d.ts +3 -0
- package/src/generators/setup-ssr/lib/add-server-file.js +31 -0
- package/src/generators/setup-ssr/lib/constants.d.ts +3 -0
- package/src/generators/setup-ssr/lib/constants.js +6 -0
- package/src/generators/setup-ssr/lib/generate-files.js +9 -11
- package/src/generators/setup-ssr/lib/generate-server-ts-config.js +7 -4
- package/src/generators/setup-ssr/lib/index.d.ts +1 -0
- package/src/generators/setup-ssr/lib/index.js +1 -0
- package/src/generators/setup-ssr/lib/update-project-config.js +17 -0
- package/src/generators/setup-ssr/setup-ssr.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/angular",
|
|
3
|
-
"version": "17.3.0
|
|
3
|
+
"version": "17.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: \n\n- Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, and Cypress. \n\n- Generators to help scaffold code quickly (like: Micro Frontends, Libraries, both internal to your codebase and publishable to npm) \n\n- Upgrading AngularJS applications \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
|
|
6
6
|
"repository": {
|
|
@@ -78,16 +78,16 @@
|
|
|
78
78
|
"tslib": "^2.3.0",
|
|
79
79
|
"webpack": "^5.80.0",
|
|
80
80
|
"webpack-merge": "^5.8.0",
|
|
81
|
-
"@nx/devkit": "17.3.0
|
|
82
|
-
"@nx/cypress": "17.3.0
|
|
83
|
-
"@nx/jest": "17.3.0
|
|
84
|
-
"@nx/js": "17.3.0
|
|
85
|
-
"@nx/eslint": "17.3.0
|
|
86
|
-
"@nx/webpack": "17.3.0
|
|
87
|
-
"@nx/web": "17.3.0
|
|
88
|
-
"@nx/workspace": "17.3.0
|
|
81
|
+
"@nx/devkit": "17.3.0",
|
|
82
|
+
"@nx/cypress": "17.3.0",
|
|
83
|
+
"@nx/jest": "17.3.0",
|
|
84
|
+
"@nx/js": "17.3.0",
|
|
85
|
+
"@nx/eslint": "17.3.0",
|
|
86
|
+
"@nx/webpack": "17.3.0",
|
|
87
|
+
"@nx/web": "17.3.0",
|
|
88
|
+
"@nx/workspace": "17.3.0",
|
|
89
89
|
"piscina": "^4.2.1",
|
|
90
|
-
"@nrwl/angular": "17.3.0
|
|
90
|
+
"@nrwl/angular": "17.3.0"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
93
|
"@angular-devkit/build-angular": ">= 15.0.0 < 18.0.0",
|
|
@@ -9,7 +9,7 @@ import <% if (standalone) { %>bootstrap<% } else { %>{ <%= rootModuleClassName %
|
|
|
9
9
|
export function app(): express.Express {
|
|
10
10
|
const server = express();
|
|
11
11
|
const serverDistFolder = dirname(fileURLToPath(import.meta.url));
|
|
12
|
-
const browserDistFolder = resolve(serverDistFolder, '
|
|
12
|
+
const browserDistFolder = resolve(serverDistFolder, '../<%= browserBundleOutputPath %>');
|
|
13
13
|
const indexHtml = join(serverDistFolder, 'index.server.html');
|
|
14
14
|
|
|
15
15
|
const commonEngine = new CommonEngine();
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addServerFile = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const version_utils_1 = require("../../utils/version-utils");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
function addServerFile(tree, schema, isUsingApplicationBuilder) {
|
|
8
|
+
const { root: projectRoot, targets } = (0, devkit_1.readProjectConfiguration)(tree, schema.project);
|
|
9
|
+
const { outputPath } = targets.build.options;
|
|
10
|
+
const browserBundleOutputPath = isUsingApplicationBuilder
|
|
11
|
+
? getApplicationBuilderBrowserOutputPath(outputPath)
|
|
12
|
+
: outputPath;
|
|
13
|
+
const pathToFiles = (0, devkit_1.joinPathFragments)(__dirname, '..', 'files');
|
|
14
|
+
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
15
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(pathToFiles, 'server', ...(isUsingApplicationBuilder
|
|
16
|
+
? ['application-builder']
|
|
17
|
+
: angularMajorVersion >= 17
|
|
18
|
+
? ['server-builder', 'v17+']
|
|
19
|
+
: ['server-builder', 'pre-v17'])), projectRoot, { ...schema, browserBundleOutputPath, tpl: '' });
|
|
20
|
+
}
|
|
21
|
+
exports.addServerFile = addServerFile;
|
|
22
|
+
function getApplicationBuilderBrowserOutputPath(outputPath) {
|
|
23
|
+
if (outputPath) {
|
|
24
|
+
if (typeof outputPath === 'string') {
|
|
25
|
+
// when `outputPath` is a string, it's the base path, so we return the default browser path
|
|
26
|
+
return constants_1.DEFAULT_BROWSER_DIR;
|
|
27
|
+
}
|
|
28
|
+
return outputPath.browser ?? constants_1.DEFAULT_BROWSER_DIR;
|
|
29
|
+
}
|
|
30
|
+
return constants_1.DEFAULT_BROWSER_DIR;
|
|
31
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_SERVER_DIR = exports.DEFAULT_MEDIA_DIR = exports.DEFAULT_BROWSER_DIR = void 0;
|
|
4
|
+
exports.DEFAULT_BROWSER_DIR = 'browser';
|
|
5
|
+
exports.DEFAULT_MEDIA_DIR = 'media';
|
|
6
|
+
exports.DEFAULT_SERVER_DIR = 'server';
|
|
@@ -6,23 +6,21 @@ const semver_1 = require("semver");
|
|
|
6
6
|
const version_utils_1 = require("../../utils/version-utils");
|
|
7
7
|
function generateSSRFiles(tree, schema, isUsingApplicationBuilder) {
|
|
8
8
|
const { root: projectRoot, targets } = (0, devkit_1.readProjectConfiguration)(tree, schema.project);
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
if (targets.server ||
|
|
10
|
+
(isUsingApplicationBuilder && targets.build.options?.server !== undefined)) {
|
|
11
|
+
// server has already been added
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
11
14
|
const pathToFiles = (0, devkit_1.joinPathFragments)(__dirname, '..', 'files');
|
|
12
|
-
const { version: angularVersion
|
|
15
|
+
const { version: angularVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
13
16
|
if (schema.standalone) {
|
|
14
|
-
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(pathToFiles, 'standalone'), projectRoot, { ...schema,
|
|
17
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(pathToFiles, 'standalone'), projectRoot, { ...schema, tpl: '' });
|
|
15
18
|
}
|
|
16
19
|
else {
|
|
17
|
-
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(pathToFiles, 'ngmodule', 'base'), projectRoot, { ...schema,
|
|
20
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(pathToFiles, 'ngmodule', 'base'), projectRoot, { ...schema, tpl: '' });
|
|
18
21
|
if ((0, semver_1.lt)(angularVersion, '15.2.0')) {
|
|
19
|
-
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(pathToFiles, 'ngmodule', 'pre-v15-2'), projectRoot, { ...schema,
|
|
22
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(pathToFiles, 'ngmodule', 'pre-v15-2'), projectRoot, { ...schema, tpl: '' });
|
|
20
23
|
}
|
|
21
24
|
}
|
|
22
|
-
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(pathToFiles, 'server', ...(isUsingApplicationBuilder
|
|
23
|
-
? ['application-builder']
|
|
24
|
-
: angularMajorVersion >= 17
|
|
25
|
-
? ['server-builder', 'v17+']
|
|
26
|
-
: ['server-builder', 'pre-v17'])), projectRoot, { ...schema, browserBundleOutputPath, tpl: '' });
|
|
27
25
|
}
|
|
28
26
|
exports.generateSSRFiles = generateSSRFiles;
|
|
@@ -7,11 +7,14 @@ function setServerTsConfigOptionsForApplicationBuilder(tree, options) {
|
|
|
7
7
|
const { targets } = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
8
8
|
const tsConfigPath = targets.build.options.tsConfig;
|
|
9
9
|
(0, devkit_1.updateJson)(tree, tsConfigPath, (json) => {
|
|
10
|
-
json.files
|
|
11
|
-
|
|
10
|
+
const files = new Set(json.files ?? []);
|
|
11
|
+
files.add((0, devkit_1.joinPathFragments)('src', options.main));
|
|
12
|
+
files.add((0, devkit_1.joinPathFragments)(options.serverFileName));
|
|
13
|
+
json.files = Array.from(files);
|
|
12
14
|
json.compilerOptions ??= {};
|
|
13
|
-
json.compilerOptions.types
|
|
14
|
-
|
|
15
|
+
const types = new Set(json.compilerOptions.types ?? []);
|
|
16
|
+
types.add('node');
|
|
17
|
+
json.compilerOptions.types = Array.from(types);
|
|
15
18
|
return json;
|
|
16
19
|
});
|
|
17
20
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./add-dependencies"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./add-server-file"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./generate-files"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./generate-server-ts-config"), exports);
|
|
7
8
|
tslib_1.__exportStar(require("./normalize-options"), exports);
|
|
@@ -3,10 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.updateProjectConfigForBrowserBuilder = exports.updateProjectConfigForApplicationBuilder = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const version_utils_1 = require("../../utils/version-utils");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
6
7
|
function updateProjectConfigForApplicationBuilder(tree, options) {
|
|
7
8
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
8
9
|
const buildTarget = project.targets.build;
|
|
10
|
+
let outputPath = buildTarget.options?.outputPath;
|
|
11
|
+
if (outputPath &&
|
|
12
|
+
typeof outputPath !== 'string' &&
|
|
13
|
+
outputPath.browser === '') {
|
|
14
|
+
const base = outputPath.base;
|
|
15
|
+
devkit_1.logger.warn(`The output location of the browser build has been updated from "${base}" to "${(0, devkit_1.joinPathFragments)(base, constants_1.DEFAULT_BROWSER_DIR)}".
|
|
16
|
+
You might need to adjust your deployment pipeline.`);
|
|
17
|
+
if ((outputPath.media && outputPath.media !== constants_1.DEFAULT_MEDIA_DIR) ||
|
|
18
|
+
(outputPath.server && outputPath.server !== constants_1.DEFAULT_SERVER_DIR)) {
|
|
19
|
+
delete outputPath.browser;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
outputPath = outputPath.base;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
9
25
|
buildTarget.options ??= {};
|
|
26
|
+
buildTarget.options.outputPath = outputPath;
|
|
10
27
|
buildTarget.options.server = (0, devkit_1.joinPathFragments)(project.sourceRoot ?? (0, devkit_1.joinPathFragments)(project.root, 'src'), options.main);
|
|
11
28
|
buildTarget.options.prerender = true;
|
|
12
29
|
buildTarget.options.ssr = {
|
|
@@ -29,6 +29,7 @@ async function setupSsr(tree, schema) {
|
|
|
29
29
|
(0, lib_1.updateProjectConfigForBrowserBuilder)(tree, options);
|
|
30
30
|
(0, lib_1.generateTsConfigServerJsonForBrowserBuilder)(tree, options);
|
|
31
31
|
}
|
|
32
|
+
(0, lib_1.addServerFile)(tree, options, isUsingApplicationBuilder);
|
|
32
33
|
if (!options.skipFormat) {
|
|
33
34
|
await (0, devkit_1.formatFiles)(tree);
|
|
34
35
|
}
|