diff --git a/docs/generated/packages/react/generators/init.json b/docs/generated/packages/react/generators/init.json index 1dc4ad03259eb..5122a0829ac2b 100644 --- a/docs/generated/packages/react/generators/init.json +++ b/docs/generated/packages/react/generators/init.json @@ -37,7 +37,7 @@ "default": false }, "skipHelperLibs": { - "description": "Do not install helpers libs (tslib, core-js, regenerator-runtime).", + "description": "Do not install tslib.", "type": "boolean", "default": false, "hidden": true diff --git a/docs/generated/packages/web/executors/webpack.json b/docs/generated/packages/web/executors/webpack.json index d132d178304f8..b326f36f4bc41 100644 --- a/docs/generated/packages/web/executors/webpack.json +++ b/docs/generated/packages/web/executors/webpack.json @@ -300,10 +300,6 @@ "description": "Extract CSS into a `.css` file.", "default": true }, - "es2015Polyfills": { - "description": "Conditional polyfills loaded in browsers which do not support `ES2015`.", - "type": "string" - }, "subresourceIntegrity": { "type": "boolean", "description": "Enables the use of subresource integrity validation.", diff --git a/docs/generated/packages/webpack/executors/webpack.json b/docs/generated/packages/webpack/executors/webpack.json index b5205f9307060..978e1a70b5f4b 100644 --- a/docs/generated/packages/webpack/executors/webpack.json +++ b/docs/generated/packages/webpack/executors/webpack.json @@ -307,10 +307,6 @@ "description": "Extract CSS into a `.css` file.", "default": true }, - "es2015Polyfills": { - "description": "Conditional polyfills loaded in browsers which do not support `ES2015`.", - "type": "string" - }, "subresourceIntegrity": { "type": "boolean", "description": "Enables the use of subresource integrity validation.", diff --git a/e2e/nx-run/src/affected-graph.test.ts b/e2e/nx-run/src/affected-graph.test.ts index b34b5be8cf389..04afebbace74e 100644 --- a/e2e/nx-run/src/affected-graph.test.ts +++ b/e2e/nx-run/src/affected-graph.test.ts @@ -597,7 +597,6 @@ describe('Nx Affected and Graph Tests', () => { expect(() => checkFilesExist('project-graph.html')).not.toThrow(); expect(() => checkFilesExist('static/styles.css')).not.toThrow(); expect(() => checkFilesExist('static/runtime.js')).not.toThrow(); - expect(() => checkFilesExist('static/polyfills.js')).not.toThrow(); expect(() => checkFilesExist('static/main.js')).not.toThrow(); expect(() => checkFilesExist('static/environment.js')).not.toThrow(); diff --git a/e2e/web/src/file-server.test.ts b/e2e/web/src/file-server.test.ts index 902f58463dd18..369569cbbed69 100644 --- a/e2e/web/src/file-server.test.ts +++ b/e2e/web/src/file-server.test.ts @@ -26,10 +26,7 @@ describe('file-server', () => { const p = await runCommandUntil( `serve ${appName} --port=${port}`, (output) => { - return ( - output.indexOf('webpack compiled') > -1 && - output.indexOf(`localhost:${port}`) > -1 - ); + return output.indexOf(`localhost:${port}`) > -1; } ); @@ -39,5 +36,5 @@ describe('file-server', () => { } catch { // ignore } - }, 1000000); + }, 300_000); }); diff --git a/e2e/web/src/web.test.ts b/e2e/web/src/web.test.ts index 2f7e345e6dfdb..c6857607704f6 100644 --- a/e2e/web/src/web.test.ts +++ b/e2e/web/src/web.test.ts @@ -112,23 +112,6 @@ describe('Web Components Applications', () => { checkFilesExist(`dist/libs/${libName}/_should_keep.txt`); }, 120000); - it('should do another build if differential loading is needed', async () => { - const appName = uniq('app'); - - runCLI( - `generate @nrwl/web:app ${appName} --bundler=webpack --no-interactive` - ); - - updateFile(`apps/${appName}/browserslist`, `IE 9-11`); - - runCLI(`build ${appName} --outputHashing=none`); - - checkFilesExist( - `dist/apps/${appName}/main.js`, - `dist/apps/${appName}/main.es5.js` - ); - }, 120000); - it('should emit decorator metadata when it is enabled in tsconfig', async () => { const appName = uniq('app'); runCLI( diff --git a/packages/react/plugins/component-testing/index.ts b/packages/react/plugins/component-testing/index.ts index 7c1a226effdf7..a463049bea941 100644 --- a/packages/react/plugins/component-testing/index.ts +++ b/packages/react/plugins/component-testing/index.ts @@ -222,7 +222,6 @@ function buildTargetWebpack( const defaultWebpack = getWebpackConfig( context, options, - true, isScriptOptimizeOn, { root: ctProjectConfig.root, diff --git a/packages/react/plugins/storybook/index.ts b/packages/react/plugins/storybook/index.ts index e62db3befd13b..38f98ba9b6914 100644 --- a/packages/react/plugins/storybook/index.ts +++ b/packages/react/plugins/storybook/index.ts @@ -1,11 +1,7 @@ import { - ExecutorContext, joinPathFragments, logger, - ProjectGraph, readJsonFile, - readNxJson, - TargetConfiguration, workspaceRoot, } from '@nrwl/devkit'; import { getBaseWebpackPartial } from '@nrwl/webpack/src/utils/config'; @@ -17,7 +13,6 @@ import { gte } from 'semver'; import { Configuration, DefinePlugin, WebpackPluginInstance } from 'webpack'; import * as mergeWebpack from 'webpack-merge'; import { mergePlugins } from './merge-plugins'; -import { readProjectsConfigurationFromProjectGraph } from 'nx/src/project-graph/project-graph'; const reactWebpackConfig = require('../webpack'); @@ -119,14 +114,12 @@ export const webpack = async ( target: 'web', }; - const esm = true; const isScriptOptimizeOn = storybookWebpackConfig.mode !== 'development'; const extractCss = storybookWebpackConfig.mode === 'production'; // ESM build for modern browsers. const baseWebpackConfig = mergeWebpack.merge([ getBaseWebpackPartial(builderOptions, { - esm, isScriptOptimizeOn, skipTypeCheck: true, }), diff --git a/packages/react/src/generators/application/application.spec.ts b/packages/react/src/generators/application/application.spec.ts index 12c42801e930b..2c2cd18375d00 100644 --- a/packages/react/src/generators/application/application.spec.ts +++ b/packages/react/src/generators/application/application.spec.ts @@ -73,7 +73,6 @@ describe('app', () => { await applicationGenerator(appTree, schema); expect(appTree.exists('apps/my-app/.babelrc')).toBeTruthy(); - expect(appTree.exists('apps/my-app/.browserslistrc')).toBeTruthy(); expect(appTree.exists('apps/my-app/src/main.tsx')).toBeTruthy(); expect(appTree.exists('apps/my-app/src/app/app.tsx')).toBeTruthy(); expect(appTree.exists('apps/my-app/src/app/app.spec.tsx')).toBeTruthy(); @@ -312,7 +311,6 @@ describe('app', () => { main: 'apps/my-app/src/main.tsx', baseHref: '/', outputPath: 'dist/apps/my-app', - polyfills: 'apps/my-app/src/polyfills.ts', scripts: [], styles: ['apps/my-app/src/styles.css'], tsConfig: 'apps/my-app/tsconfig.app.json', @@ -810,19 +808,6 @@ describe('app', () => { ).toBeUndefined(); }); - it('should add required polyfills for core-js and regenerator', async () => { - await applicationGenerator(appTree, { - ...schema, - }); - - const polyfillsSource = appTree - .read('apps/my-app/src/polyfills.ts') - .toString(); - - expect(polyfillsSource).toContain('regenerator'); - expect(polyfillsSource).toContain('core-js'); - }); - describe('--skipWorkspaceJson', () => { it('should update workspace with defaults when --skipWorkspaceJson=false', async () => { await applicationGenerator(appTree, { diff --git a/packages/react/src/generators/application/files/common/.browserslistrc__tmpl__ b/packages/react/src/generators/application/files/common/.browserslistrc__tmpl__ deleted file mode 100644 index f1d12df4faa25..0000000000000 --- a/packages/react/src/generators/application/files/common/.browserslistrc__tmpl__ +++ /dev/null @@ -1,16 +0,0 @@ -# This file is used by: -# 1. autoprefixer to adjust CSS to support the below specified browsers -# 2. babel preset-env to adjust included polyfills -# -# For additional information regarding the format and rule options, please see: -# https://github.com/browserslist/browserslist#queries -# -# If you need to support different browsers in production, you may tweak the list below. - -last 1 Chrome version -last 1 Firefox version -last 2 Edge major versions -last 2 Safari major version -last 2 iOS major versions -Firefox ESR -not IE 9-11 # For IE 9-11 support, remove 'not'. \ No newline at end of file diff --git a/packages/react/src/generators/application/files/common/src/polyfills.ts__tmpl__ b/packages/react/src/generators/application/files/common/src/polyfills.ts__tmpl__ deleted file mode 100644 index 2adf3d05b6fcf..0000000000000 --- a/packages/react/src/generators/application/files/common/src/polyfills.ts__tmpl__ +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Polyfill stable language features. These imports will be optimized by `@babel/preset-env`. - * - * See: https://github.com/zloirock/core-js#babel - */ -import 'core-js/stable'; -import 'regenerator-runtime/runtime'; diff --git a/packages/react/src/generators/application/lib/add-project.ts b/packages/react/src/generators/application/lib/add-project.ts index 804900447a4d1..384e0a84e34ca 100644 --- a/packages/react/src/generators/application/lib/add-project.ts +++ b/packages/react/src/generators/application/lib/add-project.ts @@ -57,10 +57,6 @@ function createBuildTarget(options: NormalizedSchema): TargetConfiguration { options.appProjectRoot, maybeJs(options, `src/main.tsx`) ), - polyfills: joinPathFragments( - options.appProjectRoot, - maybeJs(options, 'src/polyfills.ts') - ), tsConfig: joinPathFragments(options.appProjectRoot, 'tsconfig.app.json'), assets: [ joinPathFragments(options.appProjectRoot, 'src/favicon.ico'), diff --git a/packages/react/src/generators/init/init.ts b/packages/react/src/generators/init/init.ts index 171384eca47c3..a50b41672a581 100755 --- a/packages/react/src/generators/init/init.ts +++ b/packages/react/src/generators/init/init.ts @@ -52,8 +52,6 @@ function updateDependencies(host: Tree, schema: InitSchema) { }; if (!schema.skipHelperLibs) { - dependencies['core-js'] = '^3.6.5'; - dependencies['regenerator-runtime'] = '0.13.7'; dependencies['tslib'] = tsLibVersion; } diff --git a/packages/react/src/generators/init/schema.json b/packages/react/src/generators/init/schema.json index 1f907f6d25937..1c6800c0244a9 100644 --- a/packages/react/src/generators/init/schema.json +++ b/packages/react/src/generators/init/schema.json @@ -34,7 +34,7 @@ "default": false }, "skipHelperLibs": { - "description": "Do not install helpers libs (tslib, core-js, regenerator-runtime).", + "description": "Do not install tslib.", "type": "boolean", "default": false, "hidden": true diff --git a/packages/web/babel.ts b/packages/web/babel.ts index 602b1b10c11a9..6ff992d615d0d 100644 --- a/packages/web/babel.ts +++ b/packages/web/babel.ts @@ -43,7 +43,6 @@ module.exports = function (api: any, options: NxWebBabelPresetOptions = {}) { ? { targets: { node: 'current' }, loose: true } : { // Allow importing core-js in entrypoint and use browserlist to select polyfills. - // This is needed for differential loading as well. useBuiltIns: options.useBuiltIns ?? 'entry', corejs: 3, // Do not transform modules to CJS diff --git a/packages/web/src/executors/webpack/schema.json b/packages/web/src/executors/webpack/schema.json index 200624c469b83..51b7e81f9d6d2 100644 --- a/packages/web/src/executors/webpack/schema.json +++ b/packages/web/src/executors/webpack/schema.json @@ -176,10 +176,6 @@ "description": "Extract CSS into a `.css` file.", "default": true }, - "es2015Polyfills": { - "description": "Conditional polyfills loaded in browsers which do not support `ES2015`.", - "type": "string" - }, "subresourceIntegrity": { "type": "boolean", "description": "Enables the use of subresource integrity validation.", diff --git a/packages/web/src/generators/application/application.spec.ts b/packages/web/src/generators/application/application.spec.ts index 23179043c18e0..55c939ebebaab 100644 --- a/packages/web/src/generators/application/application.spec.ts +++ b/packages/web/src/generators/application/application.spec.ts @@ -348,7 +348,6 @@ describe('app', () => { baseHref: '/', main: 'apps/my-app/src/main.ts', outputPath: 'dist/apps/my-app', - polyfills: 'apps/my-app/src/polyfills.ts', scripts: [], styles: ['apps/my-app/src/styles.css'], tsConfig: 'apps/my-app/tsconfig.app.json', diff --git a/packages/web/src/generators/application/application.ts b/packages/web/src/generators/application/application.ts index ba7e1899edec4..634f5bc130b54 100644 --- a/packages/web/src/generators/application/application.ts +++ b/packages/web/src/generators/application/application.ts @@ -91,10 +91,6 @@ async function setupBundler(tree: Tree, options: NormalizedSchema) { 'src/index.html' ); buildOptions.baseHref = '/'; - buildOptions.polyfills = joinPathFragments( - options.appProjectRoot, - 'src/polyfills.ts' - ); buildOptions.styles = [ joinPathFragments(options.appProjectRoot, `src/styles.${options.style}`), ]; diff --git a/packages/web/src/generators/application/files/app/src/polyfills.ts__tmpl__ b/packages/web/src/generators/application/files/app/src/polyfills.ts__tmpl__ deleted file mode 100644 index 2adf3d05b6fcf..0000000000000 --- a/packages/web/src/generators/application/files/app/src/polyfills.ts__tmpl__ +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Polyfill stable language features. These imports will be optimized by `@babel/preset-env`. - * - * See: https://github.com/zloirock/core-js#babel - */ -import 'core-js/stable'; -import 'regenerator-runtime/runtime'; diff --git a/packages/webpack/migrations.json b/packages/webpack/migrations.json index 75899c88e2055..f8d499c14cae9 100644 --- a/packages/webpack/migrations.json +++ b/packages/webpack/migrations.json @@ -7,5 +7,11 @@ "factory": "./src/migrations/update-15-0-0/add-babel-inputs" } }, + "remove-es2015-polyfills-option": { + "cli": "nx", + "version": "15.4.5-beta.0", + "description": "Removes es2015Polyfills option since legacy browsers are no longer supported.", + "factory": "./src/migrations/update-15-4-5/remove-es2015-polyfills-option" + }, "packageJsonUpdates": {} } diff --git a/packages/webpack/package.json b/packages/webpack/package.json index cc257164bc849..b327f4ad9b52b 100644 --- a/packages/webpack/package.json +++ b/packages/webpack/package.json @@ -34,8 +34,6 @@ "@nrwl/workspace": "file:../workspace", "autoprefixer": "^10.4.9", "babel-loader": "^8.2.2", - "browserslist": "^4.21.4", - "caniuse-lite": "^1.0.30001394", "chalk": "4.1.0", "chokidar": "^3.5.1", "copy-webpack-plugin": "^10.2.4", diff --git a/packages/webpack/src/executors/dev-server/lib/get-dev-server-config.ts b/packages/webpack/src/executors/dev-server/lib/get-dev-server-config.ts index eae0b8b7a7605..cfbe56ca770af 100644 --- a/packages/webpack/src/executors/dev-server/lib/get-dev-server-config.ts +++ b/packages/webpack/src/executors/dev-server/lib/get-dev-server-config.ts @@ -23,7 +23,6 @@ export function getDevServerConfig( const webpackConfig = getWebpackConfig( context, buildOptions, - true, typeof buildOptions.optimization === 'boolean' ? buildOptions.optimization : buildOptions.optimization?.scripts @@ -53,7 +52,6 @@ export function getDevServerConfig( deployUrl, sri: subresourceIntegrity, moduleEntrypoints: [], - noModuleEntrypoints: ['polyfills-es5'], }) ); diff --git a/packages/webpack/src/executors/webpack/lib/get-webpack-config.ts b/packages/webpack/src/executors/webpack/lib/get-webpack-config.ts index 10cdf2f3a50af..85c5d0c82e1e0 100644 --- a/packages/webpack/src/executors/webpack/lib/get-webpack-config.ts +++ b/packages/webpack/src/executors/webpack/lib/get-webpack-config.ts @@ -1,7 +1,6 @@ import * as path from 'path'; import { posix, resolve } from 'path'; import { readTsConfig } from '@nrwl/workspace/src/utilities/typescript'; -import { ScriptTarget } from 'typescript'; import { getHashDigest, interpolateName } from 'loader-utils'; import type { Configuration } from 'webpack'; @@ -34,7 +33,6 @@ interface GetWebpackConfigOverrides { export function getWebpackConfig( context: ExecutorContext, options: NormalizedWebpackExecutorOptions, - esm?: boolean, isScriptOptimizeOn?: boolean, overrides?: GetWebpackConfigOverrides ): Configuration { @@ -53,19 +51,11 @@ export function getWebpackConfig( sourceRoot = project.sourceRoot; } - if (isScriptOptimizeOn) { - // Angular CLI uses an environment variable (NG_BUILD_DIFFERENTIAL_FULL) - // to determine whether to use the scriptTargetOverride - // or the tsConfig target - // We want to force the target if overridden - tsConfig.options.target = ScriptTarget.ES5; - } const wco: any = { root: workspaceRoot, projectRoot: resolve(workspaceRoot, projectRoot), sourceRoot: resolve(workspaceRoot, sourceRoot), buildOptions: convertBuildOptions(options), - esm, console, tsConfig, tsConfigPath: options.tsConfig, @@ -75,18 +65,12 @@ export function getWebpackConfig( _getBaseWebpackPartial( context, options, - esm, isScriptOptimizeOn, tsConfig.options.emitDecoratorMetadata, overrides ), options.target === 'web' - ? getPolyfillsPartial( - options.polyfills, - options.es2015Polyfills, - esm, - isScriptOptimizeOn - ) + ? getPolyfillsPartial(options.polyfills, isScriptOptimizeOn) : {}, options.target === 'web' ? getStylesPartial( @@ -105,7 +89,6 @@ export function getWebpackConfig( function _getBaseWebpackPartial( context: ExecutorContext, options: NormalizedWebpackExecutorOptions, - esm: boolean, isScriptOptimizeOn: boolean, emitDecoratorMetadata: boolean, overrides?: GetWebpackConfigOverrides @@ -113,7 +96,6 @@ function _getBaseWebpackPartial( let partial = getBaseWebpackPartial( options, { - esm, isScriptOptimizeOn, emitDecoratorMetadata, configuration: overrides?.configuration ?? context.configurationName, @@ -271,33 +253,23 @@ export function getStylesPartial( export function getPolyfillsPartial( polyfills: string, - es2015Polyfills: string, - esm: boolean, isScriptOptimizeOn: boolean ): Configuration { const config = { entry: {} as { [key: string]: string[] }, }; - if (polyfills && esm && isScriptOptimizeOn) { + if (polyfills && isScriptOptimizeOn) { // Safari 10.1 supports