Updated the files.
This commit is contained in:
parent
1553e6b971
commit
753967d4f5
23418 changed files with 3784666 additions and 0 deletions
14
my-app/node_modules/@schematics/angular/server/files/root/tsconfig.server.json.template
generated
vendored
Executable file
14
my-app/node_modules/@schematics/angular/server/files/root/tsconfig.server.json.template
generated
vendored
Executable file
|
@ -0,0 +1,14 @@
|
|||
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
||||
{
|
||||
"extends": "./<%= tsConfigExtends %>",
|
||||
"compilerOptions": {
|
||||
"outDir": "<%= relativePathToWorkspaceRoot %>/out-tsc/server",
|
||||
"types": [
|
||||
"node"<% if (hasLocalizePackage) { %>,
|
||||
"@angular/localize"<% } %>
|
||||
]
|
||||
},
|
||||
"files": [
|
||||
"src/main.server.ts"
|
||||
]
|
||||
}
|
14
my-app/node_modules/@schematics/angular/server/files/src/app/app.module.server.ts.template
generated
vendored
Executable file
14
my-app/node_modules/@schematics/angular/server/files/src/app/app.module.server.ts.template
generated
vendored
Executable file
|
@ -0,0 +1,14 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { ServerModule } from '@angular/platform-server';
|
||||
|
||||
import { AppModule } from './app.module';
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
AppModule,
|
||||
ServerModule,
|
||||
],
|
||||
bootstrap: [AppComponent],
|
||||
})
|
||||
export class AppServerModule {}
|
1
my-app/node_modules/@schematics/angular/server/files/src/main.server.ts.template
generated
vendored
Executable file
1
my-app/node_modules/@schematics/angular/server/files/src/main.server.ts.template
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
export { AppServerModule as default } from './app/app.module.server';
|
11
my-app/node_modules/@schematics/angular/server/files/standalone-src/app/app.config.server.ts.template
generated
vendored
Executable file
11
my-app/node_modules/@schematics/angular/server/files/standalone-src/app/app.config.server.ts.template
generated
vendored
Executable file
|
@ -0,0 +1,11 @@
|
|||
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
|
||||
import { provideServerRendering } from '@angular/platform-server';
|
||||
import { appConfig } from './app.config';
|
||||
|
||||
const serverConfig: ApplicationConfig = {
|
||||
providers: [
|
||||
provideServerRendering()
|
||||
]
|
||||
};
|
||||
|
||||
export const config = mergeApplicationConfig(appConfig, serverConfig);
|
7
my-app/node_modules/@schematics/angular/server/files/standalone-src/main.server.ts.template
generated
vendored
Executable file
7
my-app/node_modules/@schematics/angular/server/files/standalone-src/main.server.ts.template
generated
vendored
Executable file
|
@ -0,0 +1,7 @@
|
|||
import { bootstrapApplication } from '@angular/platform-browser';
|
||||
import { AppComponent } from './app/app.component';
|
||||
import { config } from './app/app.config.server';
|
||||
|
||||
const bootstrap = () => bootstrapApplication(AppComponent, config);
|
||||
|
||||
export default bootstrap;
|
10
my-app/node_modules/@schematics/angular/server/index.d.ts
generated
vendored
Executable file
10
my-app/node_modules/@schematics/angular/server/index.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import { Rule } from '@angular-devkit/schematics';
|
||||
import { Schema as ServerOptions } from './schema';
|
||||
export default function (options: ServerOptions): Rule;
|
180
my-app/node_modules/@schematics/angular/server/index.js
generated
vendored
Executable file
180
my-app/node_modules/@schematics/angular/server/index.js
generated
vendored
Executable file
|
@ -0,0 +1,180 @@
|
|||
"use strict";
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core_1 = require("@angular-devkit/core");
|
||||
const schematics_1 = require("@angular-devkit/schematics");
|
||||
const node_path_1 = require("node:path");
|
||||
const utility_1 = require("../utility");
|
||||
const dependencies_1 = require("../utility/dependencies");
|
||||
const json_file_1 = require("../utility/json-file");
|
||||
const latest_versions_1 = require("../utility/latest-versions");
|
||||
const ng_ast_utils_1 = require("../utility/ng-ast-utils");
|
||||
const paths_1 = require("../utility/paths");
|
||||
const project_targets_1 = require("../utility/project-targets");
|
||||
const util_1 = require("../utility/standalone/util");
|
||||
const workspace_1 = require("../utility/workspace");
|
||||
const workspace_models_1 = require("../utility/workspace-models");
|
||||
const serverMainEntryName = 'main.server.ts';
|
||||
function updateConfigFileBrowserBuilder(options, tsConfigDirectory) {
|
||||
return (0, workspace_1.updateWorkspace)((workspace) => {
|
||||
const clientProject = workspace.projects.get(options.project);
|
||||
if (clientProject) {
|
||||
// In case the browser builder hashes the assets
|
||||
// we need to add this setting to the server builder
|
||||
// as otherwise when assets it will be requested twice.
|
||||
// One for the server which will be unhashed, and other on the client which will be hashed.
|
||||
const getServerOptions = (options = {}) => {
|
||||
return {
|
||||
buildOptimizer: options?.buildOptimizer,
|
||||
outputHashing: options?.outputHashing === 'all' ? 'media' : options?.outputHashing,
|
||||
fileReplacements: options?.fileReplacements,
|
||||
optimization: options?.optimization === undefined ? undefined : !!options?.optimization,
|
||||
sourceMap: options?.sourceMap,
|
||||
localization: options?.localization,
|
||||
stylePreprocessorOptions: options?.stylePreprocessorOptions,
|
||||
resourcesOutputPath: options?.resourcesOutputPath,
|
||||
deployUrl: options?.deployUrl,
|
||||
i18nMissingTranslation: options?.i18nMissingTranslation,
|
||||
preserveSymlinks: options?.preserveSymlinks,
|
||||
extractLicenses: options?.extractLicenses,
|
||||
inlineStyleLanguage: options?.inlineStyleLanguage,
|
||||
vendorChunk: options?.vendorChunk,
|
||||
};
|
||||
};
|
||||
const buildTarget = clientProject.targets.get('build');
|
||||
if (buildTarget?.options) {
|
||||
buildTarget.options.outputPath = `dist/${options.project}/browser`;
|
||||
}
|
||||
const buildConfigurations = buildTarget?.configurations;
|
||||
const configurations = {};
|
||||
if (buildConfigurations) {
|
||||
for (const [key, options] of Object.entries(buildConfigurations)) {
|
||||
configurations[key] = getServerOptions(options);
|
||||
}
|
||||
}
|
||||
const sourceRoot = clientProject.sourceRoot ?? (0, core_1.join)((0, core_1.normalize)(clientProject.root), 'src');
|
||||
const serverTsConfig = (0, core_1.join)(tsConfigDirectory, 'tsconfig.server.json');
|
||||
clientProject.targets.add({
|
||||
name: 'server',
|
||||
builder: workspace_models_1.Builders.Server,
|
||||
defaultConfiguration: 'production',
|
||||
options: {
|
||||
outputPath: `dist/${options.project}/server`,
|
||||
main: (0, core_1.join)((0, core_1.normalize)(sourceRoot), serverMainEntryName),
|
||||
tsConfig: serverTsConfig,
|
||||
...(buildTarget?.options ? getServerOptions(buildTarget?.options) : {}),
|
||||
},
|
||||
configurations,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
function updateConfigFileApplicationBuilder(options) {
|
||||
return (0, workspace_1.updateWorkspace)((workspace) => {
|
||||
const project = workspace.projects.get(options.project);
|
||||
if (!project) {
|
||||
return;
|
||||
}
|
||||
const buildTarget = project.targets.get('build');
|
||||
if (buildTarget?.builder !== workspace_models_1.Builders.Application) {
|
||||
throw new schematics_1.SchematicsException(`This schematic requires "${workspace_models_1.Builders.Application}" to be used as a build builder.`);
|
||||
}
|
||||
buildTarget.options ??= {};
|
||||
buildTarget.options['server'] = node_path_1.posix.join(project.sourceRoot ?? node_path_1.posix.join(project.root, 'src'), serverMainEntryName);
|
||||
});
|
||||
}
|
||||
function updateTsConfigFile(tsConfigPath) {
|
||||
return (host) => {
|
||||
const json = new json_file_1.JSONFile(host, tsConfigPath);
|
||||
const filesPath = ['files'];
|
||||
const files = new Set(json.get(filesPath) ?? []);
|
||||
files.add('src/' + serverMainEntryName);
|
||||
json.modify(filesPath, [...files]);
|
||||
const typePath = ['compilerOptions', 'types'];
|
||||
const types = new Set(json.get(typePath) ?? []);
|
||||
types.add('node');
|
||||
json.modify(typePath, [...types]);
|
||||
};
|
||||
}
|
||||
function addDependencies(skipInstall) {
|
||||
return (host) => {
|
||||
const coreDep = (0, dependencies_1.getPackageJsonDependency)(host, '@angular/core');
|
||||
if (coreDep === null) {
|
||||
throw new schematics_1.SchematicsException('Could not find version.');
|
||||
}
|
||||
const install = skipInstall ? utility_1.InstallBehavior.None : utility_1.InstallBehavior.Auto;
|
||||
return (0, schematics_1.chain)([
|
||||
(0, utility_1.addDependency)('@angular/platform-server', coreDep.version, {
|
||||
type: utility_1.DependencyType.Default,
|
||||
install,
|
||||
}),
|
||||
(0, utility_1.addDependency)('@types/node', latest_versions_1.latestVersions['@types/node'], {
|
||||
type: utility_1.DependencyType.Dev,
|
||||
install,
|
||||
}),
|
||||
]);
|
||||
};
|
||||
}
|
||||
function default_1(options) {
|
||||
return async (host, context) => {
|
||||
const workspace = await (0, workspace_1.getWorkspace)(host);
|
||||
const clientProject = workspace.projects.get(options.project);
|
||||
if (clientProject?.extensions.projectType !== 'application') {
|
||||
throw new schematics_1.SchematicsException(`Server schematic requires a project type of "application".`);
|
||||
}
|
||||
const clientBuildTarget = clientProject.targets.get('build');
|
||||
if (!clientBuildTarget) {
|
||||
throw (0, project_targets_1.targetBuildNotFoundError)();
|
||||
}
|
||||
const isUsingApplicationBuilder = clientBuildTarget.builder === workspace_models_1.Builders.Application;
|
||||
if (clientProject.targets.has('server') ||
|
||||
(isUsingApplicationBuilder && clientBuildTarget.options?.server !== undefined)) {
|
||||
// Server has already been added.
|
||||
return;
|
||||
}
|
||||
const clientBuildOptions = clientBuildTarget.options;
|
||||
const browserEntryPoint = await (0, util_1.getMainFilePath)(host, options.project);
|
||||
const isStandalone = (0, ng_ast_utils_1.isStandaloneApp)(host, browserEntryPoint);
|
||||
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)(isStandalone ? './files/standalone-src' : './files/src'), [
|
||||
(0, schematics_1.applyTemplates)({
|
||||
...schematics_1.strings,
|
||||
...options,
|
||||
}),
|
||||
(0, schematics_1.move)((0, core_1.join)((0, core_1.normalize)(clientProject.root), 'src')),
|
||||
]);
|
||||
const clientTsConfig = (0, core_1.normalize)(clientBuildOptions.tsConfig);
|
||||
const tsConfigExtends = (0, core_1.basename)(clientTsConfig);
|
||||
const tsConfigDirectory = (0, core_1.dirname)(clientTsConfig);
|
||||
return (0, schematics_1.chain)([
|
||||
(0, schematics_1.mergeWith)(templateSource),
|
||||
...(isUsingApplicationBuilder
|
||||
? [
|
||||
updateConfigFileApplicationBuilder(options),
|
||||
updateTsConfigFile(clientBuildOptions.tsConfig),
|
||||
]
|
||||
: [
|
||||
(0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files/root'), [
|
||||
(0, schematics_1.applyTemplates)({
|
||||
...schematics_1.strings,
|
||||
...options,
|
||||
stripTsExtension: (s) => s.replace(/\.ts$/, ''),
|
||||
tsConfigExtends,
|
||||
hasLocalizePackage: !!(0, dependencies_1.getPackageJsonDependency)(host, '@angular/localize'),
|
||||
relativePathToWorkspaceRoot: (0, paths_1.relativePathToWorkspaceRoot)(tsConfigDirectory),
|
||||
}),
|
||||
(0, schematics_1.move)(tsConfigDirectory),
|
||||
])),
|
||||
updateConfigFileBrowserBuilder(options, tsConfigDirectory),
|
||||
]),
|
||||
addDependencies(options.skipInstall),
|
||||
(0, utility_1.addRootProvider)(options.project, ({ code, external }) => code `${external('provideClientHydration', '@angular/platform-browser')}()`),
|
||||
]);
|
||||
};
|
||||
}
|
||||
exports.default = default_1;
|
13
my-app/node_modules/@schematics/angular/server/schema.d.ts
generated
vendored
Executable file
13
my-app/node_modules/@schematics/angular/server/schema.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* Pass this schematic to the "run" command to set up server-side rendering for an app.
|
||||
*/
|
||||
export interface Schema {
|
||||
/**
|
||||
* The name of the project.
|
||||
*/
|
||||
project: string;
|
||||
/**
|
||||
* Do not install packages for dependencies.
|
||||
*/
|
||||
skipInstall?: boolean;
|
||||
}
|
4
my-app/node_modules/@schematics/angular/server/schema.js
generated
vendored
Executable file
4
my-app/node_modules/@schematics/angular/server/schema.js
generated
vendored
Executable file
|
@ -0,0 +1,4 @@
|
|||
"use strict";
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE
|
||||
// CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...).
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
23
my-app/node_modules/@schematics/angular/server/schema.json
generated
vendored
Executable file
23
my-app/node_modules/@schematics/angular/server/schema.json
generated
vendored
Executable file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"$id": "SchematicsAngularServerApp",
|
||||
"title": "Angular Server App Options Schema",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"description": "Pass this schematic to the \"run\" command to set up server-side rendering for an app.",
|
||||
"properties": {
|
||||
"project": {
|
||||
"type": "string",
|
||||
"description": "The name of the project.",
|
||||
"$default": {
|
||||
"$source": "projectName"
|
||||
}
|
||||
},
|
||||
"skipInstall": {
|
||||
"description": "Do not install packages for dependencies.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"required": ["project"]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue