Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ function createCodeBundleOptions(
const {
workspaceRoot,
entryPoints,
polyfills,
optimizationOptions,
sourcemapOptions,
tsconfig,
Expand Down Expand Up @@ -412,6 +411,11 @@ function createCodeBundleOptions(
},
};

const polyfills = options.polyfills ? [...options.polyfills] : [];
if (jit) {
polyfills.push('@angular/compiler');
}

if (polyfills?.length) {
const namespace = 'angular:polyfills';
buildOptions.entryPoints = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export async function getCommonConfig(wco: WebpackConfigOptions): Promise<Config
aot = true,
codeCoverageExclude = [],
main,
polyfills,
sourceMap: {
styles: stylesSourceMap,
scripts: scriptsSourceMap,
Expand Down Expand Up @@ -126,7 +125,12 @@ export async function getCommonConfig(wco: WebpackConfigOptions): Promise<Config
}
}

if (polyfills?.length) {
const polyfills = [...buildOptions.polyfills];
if (!aot) {
polyfills.push('@angular/compiler');
}

if (polyfills.length) {
// `zone.js/testing` is a **special** polyfill because when not imported in the main it fails with the below errors:
// `Error: Expected to be running in 'ProxyZone', but it was not found.`
// This was also the reason why previously it was imported in `test.ts` as the first module.
Expand Down
23 changes: 23 additions & 0 deletions tests/legacy-cli/e2e/tests/build/jit-standalone.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ng } from '../../utils/process';
import { updateJsonFile, useCIChrome, useCIDefaults } from '../../utils/project';

export default async function () {
await ng('generate', 'app', 'test-project-two', '--standalone', '--skip-install');

// Make prod use JIT.
await updateJsonFile('angular.json', (configJson) => {
const appArchitect = configJson.projects['test-project-two'].architect;
const config = appArchitect.build.configurations;
config['production'].aot = false;
config['production'].buildOptimizer = false;
config['development'].aot = false;
});

// Setup testing to use CI Chrome.
await useCIChrome('test-project-two', './e2e/');
await useCIDefaults('test-project-two');

// Test it works
await ng('e2e', '--configuration=production');
await ng('e2e', '--configuration=development');
}