build(docs-infra): remove view engine related code (#41638)

This is a pre-update to Angular 12 cleanup.

This is not needed for version 12, since applications cannot be built using View Engine.

PR Close #41638
This commit is contained in:
Alan Agius 2021-04-15 11:17:41 +02:00 committed by Andrew Kushnir
parent 89529bca0e
commit 70425539f7
12 changed files with 7 additions and 244 deletions

View File

@ -19,9 +19,6 @@ Here are the most important tasks you might need to use:
* `yarn build` - create a production build of the application (after installing dependencies, boilerplate, etc).
* `yarn build-local` - same as `build`, but use `setup-local` instead of `setup`.
* `yarn build-local-with-viewengine` - same as `build-local`, but in addition also turns on `ViewEngine` (pre-Ivy) mode in aio.
(Note: To turn on `ViewEngine` mode in docs examples, see `yarn boilerplate:add:viewengine` below.)
* `yarn start` - run a development web server that watches the files; then builds the doc-viewer and reloads the page, as necessary.
* `yarn serve-and-sync` - run both the `docs-watch` and `start` in the same console.
* `yarn lint` - check that the doc-viewer code follows our style rules.
@ -35,7 +32,6 @@ Here are the most important tasks you might need to use:
* `yarn docs-test` - run the unit tests for the doc generation code.
* `yarn boilerplate:add` - generate all the boilerplate code for the examples, so that they can be run locally.
* `yarn boilerplate:add:viewengine` - same as `boilerplate:add` but also turns on `ViewEngine` (pre-Ivy) mode.
* `yarn boilerplate:remove` - remove all the boilerplate code that was added via `yarn boilerplate:add`.
* `yarn create-example` - create a new example directory containing initial source files.
@ -46,7 +42,6 @@ Here are the most important tasks you might need to use:
- `--setup`: generate boilerplate, force webdriver update & other setup, then run tests.
- `--local`: run e2e tests with the local version of Angular contained in the "dist" folder.
_Requires `--setup` in order to take effect._
- `--viewengine`: run e2e tests in `ViewEngine` (pre-Ivy) mode.
- `--filter=foo`: limit e2e tests to those containing the word "foo".
> **Note for Windows users**

View File

@ -18,10 +18,6 @@
"build-local": "yarn ~~build",
"prebuild-local-ci": "yarn setup-local-ci",
"build-local-ci": "yarn ~~build --progress=false",
"prebuild-local-with-viewengine": "node scripts/switch-to-viewengine && yarn setup-local",
"build-local-with-viewengine": "yarn ~~build",
"prebuild-local-with-viewengine-ci": "node scripts/switch-to-viewengine && yarn setup-local-ci",
"build-local-with-viewengine-ci": "yarn ~~build --progress=false",
"extract-cli-command-docs": "node tools/transforms/cli-docs-package/extract-cli-commands.js d902a289b",
"lint": "yarn check-env && yarn docs-lint && ng lint && yarn example-lint && yarn tools-lint",
"test": "yarn check-env && ng test",
@ -65,7 +61,6 @@
"preserve-and-sync": "yarn docs",
"serve-and-sync": "run-p \"docs-watch --watch-only\" \"start {@}\" --",
"boilerplate:add": "node ./tools/examples/example-boilerplate add",
"boilerplate:add:viewengine": "yarn boilerplate:add --viewengine",
"boilerplate:remove": "node ./tools/examples/example-boilerplate remove",
"boilerplate:test": "node tools/examples/test.js",
"generate-stackblitz": "node ./tools/stackblitz-builder/generateStackblitz",

View File

@ -1,35 +0,0 @@
#!/usr/bin/env node
// Imports
const {extend, parse} = require('cjson');
const {readFileSync, writeFileSync} = require('fs');
const {join, resolve} = require('path');
// Constants
const ROOT_DIR = resolve(__dirname, '..');
const TS_CONFIG_PATH = join(ROOT_DIR, 'tsconfig.json');
const NG_COMPILER_OPTS = {
angularCompilerOptions: {
enableIvy: false,
},
};
// Run
_main(process.argv.slice(2));
// Functions - Definitions
function _main() {
// Enable ViewIngine/Disable Ivy in TS config.
console.log(`\nModifying \`${TS_CONFIG_PATH}\`...`);
const oldTsConfigStr = readFileSync(TS_CONFIG_PATH, 'utf8');
const oldTsConfigObj = parse(oldTsConfigStr);
const newTsConfigObj = extend(true, oldTsConfigObj, NG_COMPILER_OPTS);
const newTsConfigStr = `${JSON.stringify(newTsConfigObj, null, 2)}\n`;
console.log(`\nNew config: ${newTsConfigStr}`);
writeFileSync(TS_CONFIG_PATH, newTsConfigStr);
// Done.
console.log('\nReady to build with ViewEngine!');
console.log('(To switch back to Ivy (with packages from npm), undo the changes in ' +
`\`${TS_CONFIG_PATH}\` and run \`yarn aio-use-npm && yarn example-use-npm\`.)`);
}

View File

@ -47,9 +47,6 @@ Currently, the following project types are supported:
There are also the following special folders:
- `common`: Contains files used in many examples.
(See the [next section](#example-config) for info on how to exclude common files in certain examples.)
- `viewengine/cli`: Additional configuration for running CLI-based examples with `ViewEngine` (the pre-Ivy compiler/renderer).
This applies to all CLI-based examples, such as `cli-ajs`, `elements`, `getting-started`, etc.
- `viewengine/systemjs`: Additional configuration for running SystemJS-based examples with `ViewEngine` (the pre-Ivy compiler/renderer).
<a name="example-config"></a>

View File

@ -11,13 +11,12 @@ const SHARED_NODE_MODULES_PATH = path.resolve(SHARED_PATH, 'node_modules');
const BOILERPLATE_BASE_PATH = path.resolve(SHARED_PATH, 'boilerplate');
const BOILERPLATE_CLI_PATH = path.resolve(BOILERPLATE_BASE_PATH, 'cli');
const BOILERPLATE_COMMON_PATH = path.resolve(BOILERPLATE_BASE_PATH, 'common');
const BOILERPLATE_VIEWENGINE_PATH = path.resolve(BOILERPLATE_BASE_PATH, 'viewengine');
class ExampleBoilerPlate {
/**
* Add boilerplate files to all the examples
*/
add(viewengine = false) {
add() {
// Get all the examples folders, indicated by those that contain a `example-config.json` file
const exampleFolders =
this.getFoldersContaining(EXAMPLES_BASE_PATH, EXAMPLE_CONFIG_FILENAME, 'node_modules');
@ -30,9 +29,7 @@ class ExampleBoilerPlate {
'Perhaps you need to run "yarn example-use-npm" or "yarn example-use-local" to install the dependencies?');
}
if (!viewengine) {
shelljs.exec(`yarn --cwd ${SHARED_PATH} ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points`);
}
shelljs.exec(`yarn --cwd ${SHARED_PATH} ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points`);
exampleFolders.forEach(exampleFolder => {
const exampleConfig = this.loadJsonFile(path.resolve(exampleFolder, EXAMPLE_CONFIG_FILENAME));
@ -58,13 +55,6 @@ class ExampleBoilerPlate {
if (exampleConfig.useCommonBoilerplate !== false) {
this.copyDirectoryContents(BOILERPLATE_COMMON_PATH, exampleFolder, isPathIgnored);
}
// Copy ViewEngine (pre-Ivy) specific files
if (viewengine) {
const veBoilerPlateType = boilerPlateType === 'systemjs' ? 'systemjs' : 'cli';
const veBoilerPlateBasePath = path.resolve(BOILERPLATE_VIEWENGINE_PATH, veBoilerPlateType);
this.copyDirectoryContents(veBoilerPlateBasePath, exampleFolder, isPathIgnored);
}
});
}
@ -75,7 +65,7 @@ class ExampleBoilerPlate {
main() {
yargs.usage('$0 <cmd> [args]')
.command('add', 'add the boilerplate to each example', yrgs => this.add(yrgs.argv.viewengine))
.command('add', 'add the boilerplate to each example', yrgs => this.add())
.command('remove', 'remove the boilerplate from each example', () => this.remove())
.demandCommand(1, 'Please supply a command from the list above')
.argv;

View File

@ -133,66 +133,6 @@ describe('example-boilerplate tool', () => {
expect(exampleBoilerPlate.loadJsonFile).toHaveBeenCalledWith(path.resolve('a/b/example-config.json'));
expect(exampleBoilerPlate.loadJsonFile).toHaveBeenCalledWith(path.resolve('c/d/example-config.json'));
});
describe('(viewengine: true)', () => {
it('should not run `ngcc`', () => {
exampleBoilerPlate.add(true);
expect(shelljs.exec).not.toHaveBeenCalled();
});
it('should copy all the source boilerplate files for systemjs', () => {
const boilerplateDir = path.resolve(sharedDir, 'boilerplate');
exampleBoilerPlate.loadJsonFile.and.returnValue({ projectType: 'systemjs' });
exampleBoilerPlate.add(true);
expect(exampleBoilerPlate.copyDirectoryContents).toHaveBeenCalledTimes(6);
expect(exampleBoilerPlate.copyDirectoryContents.calls.allArgs()).toEqual([
[`${boilerplateDir}/systemjs`, 'a/b', jasmine.any(Function)],
[`${boilerplateDir}/common`, 'a/b', jasmine.any(Function)],
[`${boilerplateDir}/viewengine/systemjs`, 'a/b', jasmine.any(Function)],
[`${boilerplateDir}/systemjs`, 'c/d', jasmine.any(Function)],
[`${boilerplateDir}/common`, 'c/d', jasmine.any(Function)],
[`${boilerplateDir}/viewengine/systemjs`, 'c/d', jasmine.any(Function)],
]);
});
it('should copy all the source boilerplate files for cli', () => {
const boilerplateDir = path.resolve(sharedDir, 'boilerplate');
exampleBoilerPlate.loadJsonFile.and.returnValue({ projectType: 'cli' });
exampleBoilerPlate.add(true);
expect(exampleBoilerPlate.copyDirectoryContents).toHaveBeenCalledTimes(6);
expect(exampleBoilerPlate.copyDirectoryContents.calls.allArgs()).toEqual([
[`${boilerplateDir}/cli`, 'a/b', jasmine.any(Function)],
[`${boilerplateDir}/common`, 'a/b', jasmine.any(Function)],
[`${boilerplateDir}/viewengine/cli`, 'a/b', jasmine.any(Function)],
[`${boilerplateDir}/cli`, 'c/d', jasmine.any(Function)],
[`${boilerplateDir}/common`, 'c/d', jasmine.any(Function)],
[`${boilerplateDir}/viewengine/cli`, 'c/d', jasmine.any(Function)],
]);
});
it('should copy all the source boilerplate files for elements', () => {
const boilerplateDir = path.resolve(sharedDir, 'boilerplate');
exampleBoilerPlate.loadJsonFile.and.returnValue({ projectType: 'elements' });
exampleBoilerPlate.add(true);
expect(exampleBoilerPlate.copyDirectoryContents).toHaveBeenCalledTimes(8);
expect(exampleBoilerPlate.copyDirectoryContents.calls.allArgs()).toEqual([
[`${boilerplateDir}/cli`, 'a/b', jasmine.any(Function)],
[`${boilerplateDir}/elements`, 'a/b', jasmine.any(Function)],
[`${boilerplateDir}/common`, 'a/b', jasmine.any(Function)],
[`${boilerplateDir}/viewengine/cli`, 'a/b', jasmine.any(Function)],
[`${boilerplateDir}/cli`, 'c/d', jasmine.any(Function)],
[`${boilerplateDir}/elements`, 'c/d', jasmine.any(Function)],
[`${boilerplateDir}/common`, 'c/d', jasmine.any(Function)],
[`${boilerplateDir}/viewengine/cli`, 'c/d', jasmine.any(Function)],
]);
});
});
});
describe('remove', () => {

View File

@ -23,12 +23,6 @@ const DEFAULT_CLI_EXAMPLE_PORT = 4200;
const DEFAULT_CLI_SPECS_CONCURRENCY = 1;
const IGNORED_EXAMPLES = [];
const fixmeIvyExamples = [];
if (!argv.viewengine) {
IGNORED_EXAMPLES.push(...fixmeIvyExamples);
}
/**
* Run Protractor End-to-End Tests for Doc Samples
*
@ -43,8 +37,6 @@ if (!argv.viewengine) {
* Must be used in conjunction with --setup as this is when the packages are copied.
* e.g. --setup --local
*
* --viewengine to turn on `ViewEngine` mode
*
* --shard to shard the specs into groups to allow you to run them in parallel
* e.g. --shard=0/2 // the even specs: 0, 2, 4, etc
* e.g. --shard=1/2 // the odd specs: 1, 3, 5, etc
@ -61,9 +53,8 @@ function runE2e() {
// Run setup.
console.log('runE2e: setup boilerplate');
const installPackagesCommand = `example-use-${argv.local ? 'local' : 'npm'}`;
const addBoilerplateCommand = `boilerplate:add${argv.viewengine ? ':viewengine' : ''}`;
shelljs.exec(`yarn ${installPackagesCommand}`, {cwd: AIO_PATH});
shelljs.exec(`yarn ${addBoilerplateCommand}`, {cwd: AIO_PATH});
shelljs.exec(`yarn boilerplate:add`, {cwd: AIO_PATH});
}
const outputFile = path.join(AIO_PATH, './protractor-results.txt');
@ -180,14 +171,7 @@ function runE2eTestsSystemJS(appDir, outputFile) {
const appBuildSpawnInfo = spawnExt('yarn', [config.build], {cwd: appDir});
const appRunSpawnInfo = spawnExt('yarn', [config.run, '-s'], {cwd: appDir}, true);
let run = runProtractorSystemJS(appBuildSpawnInfo.promise, appDir, appRunSpawnInfo, outputFile);
// Only run AOT tests in ViewEngine mode. The current AOT setup does not work in Ivy.
// See https://github.com/angular/angular/issues/35989.
if (argv.viewengine && fs.existsSync(appDir + '/aot/index.html')) {
run = run.then((ok) => ok && runProtractorAoT(appDir, outputFile));
}
return run;
return runProtractorSystemJS(appBuildSpawnInfo.promise, appDir, appRunSpawnInfo, outputFile);
}
function runProtractorSystemJS(prepPromise, appDir, appRunSpawnInfo, outputFile) {
@ -320,14 +304,6 @@ function reportStatus(status, outputFile) {
log.push(' ' + val);
});
if (!argv.viewengine) {
log.push('');
log.push('Suites ignored due to breakage with Ivy:');
fixmeIvyExamples.forEach(function(val) {
log.push(' ' + val);
});
}
log.push('');
log.push('Suites passed:');
status.passed.forEach(function(val) {

View File

@ -1,31 +0,0 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
// TODO(gkalpak): Fix the code and enable this.
// "strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"module": "es2020",
"lib": [
"es2018",
"dom"
]
},
"angularCompilerOptions": {
"enableIvy": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}

View File

@ -1,22 +0,0 @@
// #docregion
import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs';
import {terser} from 'rollup-plugin-terser'
//paths are relative to the execution path
export default {
input: 'app/main-aot.js',
output: {
file: 'aot/dist/build.js', // output a single application bundle
format: 'iife',
sourcemap: true,
sourcemapFile: 'aot/dist/build.js.map'
},
plugins: [
nodeResolve({jsnext: true, module: true}),
commonjs({
include: ['node_modules/rxjs/**']
}),
terser()
]
}

View File

@ -1,29 +0,0 @@
{
"compilerOptions": {
"target": "es5",
"module": "es2020",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2015",
"dom"
],
"removeComments": false,
"noImplicitAny": true,
"skipLibCheck": true,
"suppressImplicitAnyIndexErrors": true,
"typeRoots": [
"node_modules/@types"
]
},
"files": [
"app/app.module.ts",
"app/main-aot.ts"
],
"angularCompilerOptions": {
"enableIvy": false,
"skipMetadataEmit": true
}
}

View File

@ -7,21 +7,17 @@
* ```
*
* Updates the dependency versions of the top-level `package.json` files in each sub-folder of
* `./boilerplate/` and `./boilerplate/viewengine/` to match the ones in `./package.json`.
* `./boilerplate/` to match the ones in `./package.json`.
*/
const fs = require('fs');
const path = require('path');
const BOILERPLATE_DIR = `${__dirname}/boilerplate`;
const VIEWENGINE_DIR = `${BOILERPLATE_DIR}/viewengine`;
const SHARED_PACKAGE_JSON_PATH = `${__dirname}/package.json`;
const sharedPkgJson = loadJsonFile(SHARED_PACKAGE_JSON_PATH);
const boilerplatePkgJsonPaths = [
...collectPackageJsonFiles(BOILERPLATE_DIR),
...collectPackageJsonFiles(VIEWENGINE_DIR),
];
const boilerplatePkgJsonPaths = collectPackageJsonFiles(BOILERPLATE_DIR);
boilerplatePkgJsonPaths.forEach(syncDependencies);

View File

@ -16,14 +16,5 @@
"polyfills-es2015": 55230
}
}
},
"aio-local-viewengine": {
"master": {
"uncompressed": {
"runtime-es2015": 3153,
"main-es2015": 438824,
"polyfills-es2015": 55230
}
}
}
}