diff --git a/.bitmap b/.bitmap index 29b9af03..07a08e7f 100644 --- a/.bitmap +++ b/.bitmap @@ -12,7 +12,7 @@ "angular-env": { "name": "angular-env", "scope": "bitdev.angular", - "version": "7.0.1", + "version": "7.1.0", "mainFile": "index.ts", "rootDir": "angular/envs/angular-env" }, @@ -250,112 +250,112 @@ "envs/angular-v16-env": { "name": "envs/angular-v16-env", "scope": "bitdev.angular", - "version": "7.0.0", + "version": "7.1.0", "mainFile": "index.ts", "rootDir": "angular/envs/angular-v16-env" }, "envs/angular-v17-env": { "name": "envs/angular-v17-env", "scope": "bitdev.angular", - "version": "6.0.0", + "version": "6.1.0", "mainFile": "index.ts", "rootDir": "angular/envs/angular-v17-env" }, "envs/angular-v18-env": { "name": "envs/angular-v18-env", "scope": "bitdev.angular", - "version": "2.0.0", + "version": "2.1.0", "mainFile": "index.ts", "rootDir": "angular/envs/angular-v18-env" }, "envs/angular-v19-env": { "name": "envs/angular-v19-env", "scope": "bitdev.angular", - "version": "1.0.1", + "version": "1.1.0", "mainFile": "index.ts", "rootDir": "angular/envs/angular-v19-env" }, "envs/base-env": { "name": "envs/base-env", "scope": "bitdev.angular", - "version": "7.0.0", + "version": "7.1.0", "mainFile": "index.ts", "rootDir": "angular/envs/base-env" }, "examples/my-angular-env": { "name": "examples/my-angular-env", "scope": "bitdev.angular", - "version": "7.0.3", + "version": "7.1.0", "mainFile": "index.ts", "rootDir": "angular/examples/my-angular-env" }, "examples/my-angular-v16-env": { "name": "examples/my-angular-v16-env", "scope": "bitdev.angular", - "version": "6.0.2", + "version": "6.1.0", "mainFile": "index.ts", "rootDir": "angular/examples/my-angular-v16-env" }, "examples/my-angular-v17-env": { "name": "examples/my-angular-v17-env", "scope": "bitdev.angular", - "version": "6.0.2", + "version": "6.1.0", "mainFile": "index.ts", "rootDir": "angular/examples/my-angular-v17-env" }, "examples/my-angular-v18-env": { "name": "examples/my-angular-v18-env", "scope": "bitdev.angular", - "version": "2.0.2", + "version": "2.1.0", "mainFile": "index.ts", "rootDir": "angular/examples/my-angular-v18-env" }, "examples/my-angular-v19-env": { "name": "examples/my-angular-v19-env", "scope": "bitdev.angular", - "version": "1.0.3", + "version": "1.1.0", "mainFile": "index.ts", "rootDir": "angular/examples/my-angular-v19-env" }, "integration/demo-app": { "name": "integration/demo-app", "scope": "bitdev.angular", - "version": "1.0.1", + "version": "1.1.0", "mainFile": "index.ts", "rootDir": "angular/integration/demo-app" }, "integration/demo-lib": { "name": "integration/demo-lib", "scope": "bitdev.angular", - "version": "1.0.1", + "version": "1.1.0", "mainFile": "public-api.ts", "rootDir": "angular/integration/demo-lib" }, "integration/demo-lib-v16": { "name": "integration/demo-lib-v16", "scope": "bitdev.angular", - "version": "1.0.0", + "version": "1.1.0", "mainFile": "public-api.ts", "rootDir": "angular/integration/demo-lib-v16" }, "integration/demo-lib-v17": { "name": "integration/demo-lib-v17", "scope": "bitdev.angular", - "version": "1.0.0", + "version": "1.1.0", "mainFile": "public-api.ts", "rootDir": "angular/integration/demo-lib-v17" }, "integration/demo-lib-v18": { "name": "integration/demo-lib-v18", "scope": "bitdev.angular", - "version": "1.0.0", + "version": "1.1.0", "mainFile": "public-api.ts", "rootDir": "angular/integration/demo-lib-v18" }, "integration/demo-lib-v19": { "name": "integration/demo-lib-v19", "scope": "bitdev.angular", - "version": "1.0.1", + "version": "1.1.0", "mainFile": "public-api.ts", "rootDir": "angular/integration/demo-lib-v19" }, @@ -369,7 +369,7 @@ "templates/generators": { "name": "templates/generators", "scope": "bitdev.angular", - "version": "7.0.0", + "version": "7.1.0", "mainFile": "index.ts", "rootDir": "angular/templates/generators" }, diff --git a/angular/envs/angular-env/component.json b/angular/envs/angular-env/component.json index 33317681..3898d73c 100644 --- a/angular/envs/angular-env/component.json +++ b/angular/envs/angular-env/component.json @@ -2,7 +2,7 @@ "componentId": { "scope": "bitdev.angular", "name": "angular-env", - "version": "7.0.1" + "version": "7.1.0" }, "propagate": false, "extensions": { @@ -44,7 +44,7 @@ "jest": "^29.5.0", "jest-environment-jsdom": "^29.0.3", "jest-environment-node": "^29.0.3", - "jest-preset-angular": "~14.3.0", + "jest-preset-angular": "~14.4.0", "ng-packagr": "^19.0.0", "postcss": "8.4.47", "postcss-loader": "8.1.1", diff --git a/angular/envs/angular-env/env.jsonc b/angular/envs/angular-env/env.jsonc index 4fd5c7e1..d345a517 100644 --- a/angular/envs/angular-env/env.jsonc +++ b/angular/envs/angular-env/env.jsonc @@ -39,8 +39,8 @@ }, { "name": "jest-preset-angular", - "version": "~14.3.0", - "supportedRange": "~14.3.0", + "version": "~14.4.0", + "supportedRange": "~14.4.0", "hidden": true, "force": true } @@ -106,6 +106,11 @@ "version": "^19.0.0", "supportedRange": "^19.0.0" }, + { + "name": "@types/eslint", + "version": "^8.40.0", + "supportedRange": "^8.40.0" + }, { "name": "express", "version": "~4.21.1", diff --git a/angular/envs/angular-v13-env/angular-v13-env.bit-env.ts b/angular/envs/angular-v13-env/angular-v13-env.bit-env.ts deleted file mode 100644 index 18b65405..00000000 --- a/angular/envs/angular-v13-env/angular-v13-env.bit-env.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { AngularEnvOptions } from '@bitdev/angular.dev-services.common'; -import { AngularBaseEnv } from '@bitdev/angular.envs.base-env'; -import { NativeCompileCache } from '@teambit/toolbox.performance.v8-cache'; -import { createRequire } from 'node:module'; -import { webpackConfigFactory } from './webpack-config.factory.js'; - -// Disable v8-caching because it breaks ESM loaders -NativeCompileCache.uninstall(); - -const require = createRequire(import.meta.url); - -export const ngEnvOptions: AngularEnvOptions = { - useAngularElementsPreview: false, - // angularElementsModulePath: require.resolve('@angular/elements'), - jestConfigPath: require.resolve('./jest/jest.config.cjs'), - jestModulePath: require.resolve('jest'), - ngPackagrModulePath: import.meta.resolve('ng-packagr'), - webpackConfigFactory, - webpackDevServerModulePath: require.resolve('webpack-dev-server'), - // resolving to the webpack used by angular devkit to avoid multiple instances of webpack - // otherwise, if we use a different version, it would break - webpackModulePath: require.resolve('webpack', { paths: [require.resolve('@angular-devkit/build-angular')] }) -} - -export class AngularV13Env extends AngularBaseEnv { - /** - * name of the environment. used for friendly mentions across bit. - */ - name = 'angular-v13-env'; - - angularVersion = 13; - - ngEnvOptions: AngularEnvOptions = ngEnvOptions; -} - -export default new AngularV13Env(); diff --git a/angular/envs/angular-v13-env/angular-v13-env.docs.mdx b/angular/envs/angular-v13-env/angular-v13-env.docs.mdx deleted file mode 100644 index df055655..00000000 --- a/angular/envs/angular-v13-env/angular-v13-env.docs.mdx +++ /dev/null @@ -1,85 +0,0 @@ ---- -description: A Bit development environment for Angular Components -labels: ['angular', 'environment', 'env', 'aspect', 'extension'] ---- - -import { EnvOverview } from '@teambit/envs.docs.env-overview-template'; - - diff --git a/angular/envs/angular-v13-env/component.json b/angular/envs/angular-v13-env/component.json deleted file mode 100644 index 12b98831..00000000 --- a/angular/envs/angular-v13-env/component.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "componentId": { - "scope": "bitdev.angular", - "name": "envs/angular-v13-env", - "version": "6.0.13" - }, - "propagate": false, - "extensions": { - "teambit.dependencies/dependency-resolver": { - "policy": { - "dependencies": { - "@angular-devkit/architect": "~0.1302.1", - "@angular-devkit/build-angular": "~13.2.1", - "@angular-devkit/build-optimizer": "~0.1302.1", - "@angular-devkit/build-webpack": "~0.1302.1", - "@angular-devkit/core": "~13.2.1", - "@angular-devkit/schematics": "~13.2.1", - "@angular-eslint/eslint-plugin": "~13.0.1", - "@angular-eslint/eslint-plugin-template": "~13.0.1", - "@angular-eslint/template-parser": "~13.0.1", - "@angular/animations": "~13.2.0", - "@angular/cli": "~13.2.0", - "@angular/common": "~13.2.0", - "@angular/compiler": "~13.2.0", - "@angular/compiler-cli": "~13.2.0", - "@angular/core": "~13.2.0", - "@angular/elements": "~13.2.0", - "@angular/platform-browser": "~13.2.0", - "@angular/platform-browser-dynamic": "~13.2.0", - "@ngtools/webpack": "~13.2.1", - "@types/eslint": "^8.2.0", - "@types/jest": "^27.0.3", - "@types/react-dev-utils": "~9.0.8", - "@types/remark-prism": "~1.3.0", - "@types/webpack-dev-server": "4.3.1", - "@types/webpack-dev-middleware": "5.0.2", - "@typescript-eslint/eslint-plugin": "^5.3.0", - "@typescript-eslint/parser": "^5.3.0", - "eslint": "8.2.0", - "events": "^3.2.0", - "html-loader": "~2.1.2", - "jest": "^27.4.4", - "jest-preset-angular": "~11.0.1", - "ng-packagr": "~13.2.1", - "remark": "~13.0.0", - "remark-loader": "~4.0.0", - "rxjs": "~7.4.0", - "ts-node": "^9.1.1", - "tslib": "^2.3.0", - "typescript": "~4.5.2", - "webpack": "5.60.0", - "webpack-dev-middleware": "5.2.1", - "webpack-dev-server": "4.4.0", - "zone.js": "~0.14.0" - } - } - }, - "bitdev.general/envs/bit-env@1.0.1": {}, - "teambit.envs/envs": {}, - "teambit.component/renaming": { - "renamedFrom": { - "scope": "bitdev.angular", - "name": "envs/v13", - "version": "6b894fe169bc5c2ac795be3338da8b321063f0c3" - } - } - } -} diff --git a/angular/envs/angular-v13-env/env.jsonc b/angular/envs/angular-v13-env/env.jsonc deleted file mode 100644 index 7e80be8e..00000000 --- a/angular/envs/angular-v13-env/env.jsonc +++ /dev/null @@ -1,126 +0,0 @@ -/** - * define the peer dependencies for your environment. - * these components would be resolved once for all components in - * in the dependency graph of your component. - **/ - { - "policy": { - "runtime": [ - { - "name": "tslib", - "version": "^2.3.0", - "supportedRange": "^2.3.0" - } - ], - /** - * dev dependencies resolved in the workspace - * for components using this env. these dependencies would not be defined - * as a direct component dependencies. they are used for component development only. - **/ - "dev": [ - { - "name": "@types/jest", - "version": "^27.0.3", - "supportedRange": "^27.0.0", - "hidden": true, - "force": true - }, - { - "name": "@types/node", - "version": "^12.11.1", - "hidden": true, - "force": true - }, - { - "name": "jest-preset-angular", - "version": "~11.0.1", - "supportedRange": "~11.0.1", - "hidden": true, - "force": true - } - ], - "peers": [ - { - "name": "@angular/animations", - "version": "~13.2.0", - "supportedRange": "^13.0.0" - }, - { - "name": "@angular/common", - "version": "~13.2.0", - "supportedRange": "^13.0.0" - }, - { - "name": "@angular/compiler", - "version": "~13.2.0", - "supportedRange": "^13.0.0" - }, - { - "name": "@angular/compiler-cli", - "version": "~13.2.0", - "supportedRange": "^13.0.0" - }, - { - "name": "@angular/core", - "version": "~13.2.0", - "supportedRange": "^13.0.0" - }, - { - "name": "@angular/forms", - "version": "~13.2.0", - "supportedRange": "^13.0.0" - }, - { - "name": "@angular/platform-browser", - "version": "~13.2.0", - "supportedRange": "^13.0.0" - }, - { - "name": "@angular/platform-browser-dynamic", - "version": "~13.2.0", - "supportedRange": "^13.0.0" - }, - { - "name": "@angular/router", - "version": "~13.2.0", - "supportedRange": "^13.0.0" - }, - { - "name": "jest", - "version": "^27.4.4", - "supportedRange": "^27.4.0" - }, - { - "name": "rxjs", - "version": "~7.4.0", - "supportedRange": "^6.5.5 || ^7.4.0" - }, - { - "name": "tslib", - "version": "^2.3.0", - "supportedRange": "^2.3.0" - }, - { - "name": "typescript", - "version": "~4.5.2", - "supportedRange": ">=4.4.4 <4.6.0" - }, - { - "name": "zone.js", - "version": "~0.14.0", - "supportedRange": "~0.14.0" - } - ] - }, - - /** - * used to define patterns to different - * files in your component and associate them with - * bit aspects. - **/ - "patterns": { - "compositions": ["**/*.composition.*", "**/*.preview.*"], - "docs": ["**/*.docs.*"], - "tests": ["**/*.spec.*", "**/*.test.*", "**/*.cy.*"] - } -} diff --git a/angular/envs/angular-v13-env/index.ts b/angular/envs/angular-v13-env/index.ts deleted file mode 100644 index c301298d..00000000 --- a/angular/envs/angular-v13-env/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { AngularV13Env, ngEnvOptions } from './angular-v13-env.bit-env.js'; -// @ts-ignore -export { default as jestConfig } from './jest/jest.config.cjs'; diff --git a/angular/envs/angular-v13-env/jest/jest.config.cjs b/angular/envs/angular-v13-env/jest/jest.config.cjs deleted file mode 100644 index 49e64845..00000000 --- a/angular/envs/angular-v13-env/jest/jest.config.cjs +++ /dev/null @@ -1,27 +0,0 @@ -const { generateNodeModulesPattern } = require('@teambit/dependencies.modules.packages-excluder'); - -const packagesToExclude = ['@angular', '@ngrx', 'apollo-angular']; - -module.exports = { - preset: 'jest-preset-angular', - reporters: ['default'], - setupFilesAfterEnv: [require.resolve('./setup-jest.cjs')], - testPathIgnorePatterns: ['/.*/e2e/'], - globals: { - 'ts-jest': { - tsconfig: require.resolve('./tsconfig.spec.json'), - }, - }, - moduleNameMapper: { - // map angular modules to avoid duplicated modules - /* eslint-disable-next-line no-useless-escape */ - "(@angular\/.*)$": ["/node_modules/$1", "$1"] - }, - transformIgnorePatterns: [ - '^.+.module.(css|sass|scss)$', - generateNodeModulesPattern({ - packages: packagesToExclude, - excludeComponents: true, - }), - ], -}; diff --git a/angular/envs/angular-v13-env/jest/jest.config.d.ts b/angular/envs/angular-v13-env/jest/jest.config.d.ts deleted file mode 100644 index 52228a47..00000000 --- a/angular/envs/angular-v13-env/jest/jest.config.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { Config } from 'jest'; - -declare const config: Config; -export default config; \ No newline at end of file diff --git a/angular/envs/angular-v13-env/jest/setup-jest.cjs b/angular/envs/angular-v13-env/jest/setup-jest.cjs deleted file mode 100644 index 7eacc2fd..00000000 --- a/angular/envs/angular-v13-env/jest/setup-jest.cjs +++ /dev/null @@ -1,9 +0,0 @@ -/* eslint-disable */ -require('jest-preset-angular/build/utils/reflect-metadata'); -require('zone.js'); -require('zone.js/bundles/zone-testing.umd'); -const getTestBed = require('@angular/core/testing').getTestBed; -const BrowserDynamicTestingModule = require('@angular/platform-browser-dynamic/testing').BrowserDynamicTestingModule; -const platformBrowserDynamicTesting = require('@angular/platform-browser-dynamic/testing') - .platformBrowserDynamicTesting; -getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); diff --git a/angular/envs/angular-v13-env/jest/tsconfig.spec.json b/angular/envs/angular-v13-env/jest/tsconfig.spec.json deleted file mode 100644 index ded6b39e..00000000 --- a/angular/envs/angular-v13-env/jest/tsconfig.spec.json +++ /dev/null @@ -1,5 +0,0 @@ -/* To learn more about this file see: https://angular.io/config/tsconfig. */ -{ - "extends": "@bitdev/angular.envs.base-env/config/tsconfig.json", - "include": ["**/*.spec.+(js|ts)", "**/*.test.+(js|ts)", "**/*.d.ts"] -} diff --git a/angular/envs/angular-v13-env/tsconfig.json b/angular/envs/angular-v13-env/tsconfig.json deleted file mode 100644 index ee229f3a..00000000 --- a/angular/envs/angular-v13-env/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -// bit-generated-typescript-config - -{ - "extends": "./../../../node_modules/.cache/tsconfig.bit.f3b87b1c18fb9e87952d48c4888ed71964a4999d.json" -} \ No newline at end of file diff --git a/angular/envs/angular-v13-env/webpack-config.factory.ts b/angular/envs/angular-v13-env/webpack-config.factory.ts deleted file mode 100644 index 5528c8a3..00000000 --- a/angular/envs/angular-v13-env/webpack-config.factory.ts +++ /dev/null @@ -1,261 +0,0 @@ -/* eslint-disable no-param-reassign */ -import { OutputHashing } from '@angular-devkit/build-angular'; -import { getSystemPath, normalize, tags } from '@angular-devkit/core'; -import { BundlerSetup, dedupPaths, getLoggerApi } from '@bitdev/angular.dev-services.common'; -import type { BrowserBuilderOptions } from '@bitdev/angular.dev-services.ng-compat'; -import { - generateEntryPoints, - generateWebpackConfig, - getCommonConfig, - getDevServerConfig, - getIndexOutputFile, - getStylesConfig, - IndexHtmlWebpackPlugin, - normalizeBrowserSchema, - normalizeCacheOptions, - normalizeOptimization -} from '@bitdev/angular.dev-services.ng-compat'; -import { - WebpackBuildConfigFactoryOpts, - WebpackConfig, - WebpackConfigFactoryOpts, - WebpackServeConfigFactoryOpts -} from '@bitdev/angular.dev-services.webpack'; -import { BundlerContext, DevServerContext } from '@teambit/bundler'; -import { Logger } from '@teambit/logger'; -import { - runTransformersWithContext, - WebpackConfigMutator, - WebpackConfigTransformer, - WebpackConfigWithDevServer -} from '@teambit/webpack'; -import assert from 'assert'; -import { join, posix, resolve } from 'path'; -import { Configuration } from 'webpack'; -import { webpack5BuildConfigFactory } from './webpack/webpack5.build.config.js'; -import { webpack5ServeConfigFactory } from './webpack/webpack5.serve.config.js'; - -/** - * Migrate options from webpack-dev-server 3 to 4 - */ -function migrateConfiguration(webpackConfig: any): WebpackConfigWithDevServer | Configuration { - /** - * Removed logLevel in favor of built-in logger - * see https://webpack.js.org/configuration/other-options/#infrastructurelogginglevel - */ - delete webpackConfig.devServer.logLevel; - - // Removed contentBase in favor of the static option - delete webpackConfig.devServer.contentBase; - - // Removed publicPath in favor of the dev option - delete webpackConfig.devServer.publicPath; - - // Moved overlay to client option - webpackConfig.devServer.client = webpackConfig.devServer.client || {}; - webpackConfig.devServer.client.overlay = webpackConfig.devServer.overlay; - delete webpackConfig.devServer.overlay; - - // Removed in favor of the static option - delete webpackConfig.devServer.watchOptions; - - // Moved sockPath to client.webSocketURL.pathname option - // We let webpack handle that now - delete webpackConfig.devServer.sockPath; - - // Removed stats in favor of the stats options from webpack - delete webpackConfig.devServer.stats; - - // Removed in favor client.webSocketURL options - delete webpackConfig.devServer.public; - - // Removed watch to avoid "DEP_WEBPACK_WATCH_WITHOUT_CALLBACK" warning - delete webpackConfig.watch; - - // Removed in favor of manual setup entries. - delete webpackConfig.devServer.injectClient; - - // Cleaning up undefined values - Object.keys(webpackConfig.devServer).forEach((option) => { - if (typeof webpackConfig.devServer[option] === 'undefined') { - delete webpackConfig.devServer[option]; - } - }); - - delete webpackConfig.devServer.devMiddleware.publicPath; - delete webpackConfig.devServer.webSocketServer; - delete webpackConfig.devServer.client; - - return webpackConfig; -} - -async function getWebpackConfig( - _context: DevServerContext | BundlerContext, - entryFiles: string[], - tsconfigPath: string, - workspaceRoot: string, - logger: Logger, - setup: BundlerSetup, - angularOptions: Partial = {}, - sourceRoot = 'src' -): Promise { - assert(!(angularOptions as any).server, "SSR is only available for Angular v16+"); - - // Options from angular.json - const browserOptions: BrowserBuilderOptions = { - ...angularOptions, - baseHref: angularOptions.baseHref ?? './', - preserveSymlinks: false, - outputPath: 'public', // doesn't matter because it will be deleted from the config - index: angularOptions.index ?? join(sourceRoot, `index.html`), - main: angularOptions.main ?? join(sourceRoot, `main.ts`), - polyfills: angularOptions.polyfills ?? join(sourceRoot, `polyfills.ts`), - tsConfig: angularOptions.tsConfig ?? tsconfigPath, - assets: dedupPaths([posix.join(sourceRoot, `favicon.ico`), posix.join(sourceRoot, `assets`), ...(angularOptions.assets ?? [])]), - styles: dedupPaths([posix.join(sourceRoot, `styles.${ angularOptions.inlineStyleLanguage ?? 'scss' }`), ...(angularOptions.styles ?? [])]), - scripts: angularOptions.scripts, - vendorChunk: angularOptions.vendorChunk ?? true, - namedChunks: angularOptions.namedChunks ?? true, - optimization: angularOptions.optimization ?? setup === BundlerSetup.Build, - buildOptimizer: angularOptions.buildOptimizer ?? setup === BundlerSetup.Build, - aot: angularOptions.aot ?? true, - deleteOutputPath: angularOptions.deleteOutputPath ?? true, - sourceMap: angularOptions.sourceMap ?? true, - outputHashing: angularOptions.outputHashing ?? (setup === BundlerSetup.Build ? OutputHashing.All : OutputHashing.None), - watch: setup === BundlerSetup.Serve, - allowedCommonJsDependencies: ['dompurify', '@teambit/harmony', '@teambit/preview', 'graphql', '@teambit/documenter.ng.content.copy-box', ...(angularOptions.allowedCommonJsDependencies || [])], - }; - - const normalizedWorkspaceRoot = normalize(workspaceRoot); - // used to load component config files, such as tailwind config, ... - const projectRoot = normalize(workspaceRoot); - const normalizedSourceRoot = normalize(sourceRoot); - - const normalizedOptions = normalizeBrowserSchema( - normalizedWorkspaceRoot, - projectRoot, - normalizedSourceRoot, - { - ...browserOptions - }, - { - cli: { - cache: { - // disable webpack cache for now because it seems to cause an infinite loop - // TODO(ocombe): investigate this, maybe change the path? - enabled: false - } - } - } - ); - - const loggerApi = getLoggerApi(logger); - - let webpackConfig: any = await generateWebpackConfig( - getSystemPath(normalizedWorkspaceRoot), - getSystemPath(projectRoot), - getSystemPath(normalizedSourceRoot), - 'bit-angular-v13-env', // projectName - normalizedOptions, - (wco: any) => [ - setup === BundlerSetup.Serve ? getDevServerConfig(wco) : {}, - getCommonConfig(wco), - getStylesConfig(wco), - ], - loggerApi, - {} - ); - - // @ts-ignore - if (angularOptions.hmr) { - logger.warn(tags.stripIndents`NOTICE: Hot Module Replacement (HMR) is enabled for the dev server. - See https://webpack.js.org/guides/hot-module-replacement for information on working with HMR for Webpack.`); - } - - // Add bit generated files to the list of entries - webpackConfig.entry.main.unshift(...entryFiles); - - const { scripts = [], styles = [] } = browserOptions; - const entrypoints = generateEntryPoints({ scripts, styles }); - const normalizedIndex = normalize(browserOptions.index as string); - const normalizedOptimization = normalizeOptimization(browserOptions.optimization); - if (!webpackConfig.plugins) { - webpackConfig.plugins = []; - } - const cacheOptions = normalizeCacheOptions({}, workspaceRoot); - webpackConfig.plugins.push( - new IndexHtmlWebpackPlugin({ - indexPath: resolve(workspaceRoot, browserOptions.index as string), - outputPath: getIndexOutputFile(normalizedIndex), - baseHref: browserOptions.baseHref || '/', - entrypoints, - deployUrl: browserOptions.deployUrl, - sri: browserOptions.subresourceIntegrity, - cache: cacheOptions, - postTransform: undefined, // IndexHtmlTransform - optimization: normalizedOptimization, - crossOrigin: browserOptions.crossOrigin, - lang: 'en-US', // TODO(ocombe) support locale - }) - ); - - // don't use the output path from angular - delete webpackConfig?.output?.path; - delete webpackConfig?.resolve?.modules; - webpackConfig.stats = 'errors-only'; - // uniqueName should not be an empty string - webpackConfig.output.uniqueName = 'angular-v13-env'; - - if (setup === BundlerSetup.Serve) { - webpackConfig = migrateConfiguration(webpackConfig); - } - - return webpackConfig; -} - -export async function webpackConfigFactory(opts: WebpackConfigFactoryOpts & WebpackServeConfigFactoryOpts & WebpackBuildConfigFactoryOpts): Promise { - const baseConfig = await getWebpackConfig( - opts.context, - opts.entryFiles, - opts.tsConfigPath, - opts.rootPath, - opts.logger, - opts.setup, - opts.angularOptions, - opts.sourceRoot - ) as WebpackConfigWithDevServer; - - let overwriteConfig: WebpackConfigWithDevServer; - if (opts.setup === BundlerSetup.Serve) { - overwriteConfig = webpack5ServeConfigFactory( - opts.devServerID, - opts.workspaceDir, - opts.entryFiles, - opts.publicRoot, - opts.publicPath, - opts.pubsub, - opts.nodeModulesPaths, - opts.tempFolder, - opts.plugins, - opts.isApp, - ); - } else { - overwriteConfig = webpack5BuildConfigFactory( - opts.entryFiles, - opts.outputPath, - opts.nodeModulesPaths, - opts.workspaceDir, - opts.tempFolder, - opts.plugins, - ) as any; - } - - const transformer: WebpackConfigTransformer = configMutator => configMutator.merge([baseConfig]); - const configMutator = new WebpackConfigMutator(overwriteConfig); - const afterMutation = runTransformersWithContext( - configMutator.clone(), - [transformer], - { mode: 'dev' } - ); - return afterMutation.raw as WebpackConfigWithDevServer; -} diff --git a/angular/envs/angular-v13-env/webpack/module-rules.config.ts b/angular/envs/angular-v13-env/webpack/module-rules.config.ts deleted file mode 100644 index bfdf9b8c..00000000 --- a/angular/envs/angular-v13-env/webpack/module-rules.config.ts +++ /dev/null @@ -1,142 +0,0 @@ -import { generateStyleLoaders } from '@teambit/webpack.modules.generate-style-loaders'; -import * as stylesRegexps from '@teambit/webpack.modules.style-regexps'; -import { merge } from 'lodash-es'; -import { createRequire } from 'node:module'; -// @ts-ignore -import getLocalIdent from 'react-dev-utils-esm/getCSSModuleLocalIdent.js'; -import RemarkFrontmatter from 'remark-frontmatter'; -import RemarkHTML from 'remark-html'; -import RemarkPrism from 'remark-prism'; -import { RuleSetRule } from 'webpack'; - -const require = createRequire(import.meta.url); - -const postCssConfig = { - // Necessary for external CSS imports to work - // https://github.com/facebook/create-react-app/issues/2677 - ident: 'postcss', - plugins: [ - // eslint-disable-next-line global-require - require.resolve('postcss-flexbugs-fixes'), - // eslint-disable-next-line global-require - require('postcss-preset-env')({ - autoprefixer: { - flexbox: 'no-2009', - }, - stage: 3, - }), - // Adds PostCSS Normalize as the reset css with default options, - // so that it honors browserslist config in package.json - // which in turn lets users customize the target behavior as per their needs. - // require.resolve('postcss-normalize'), - ], -}; - -const styleLoaderPath = require.resolve('style-loader'); - -// Source maps are resource heavy and can cause out of memory issue for large source files. -const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false'; - -export function getModuleRulesConfig(isEnvProduction: boolean): RuleSetRule[] { - const baseStyleLoadersOptions = { - injectingLoader: styleLoaderPath, - cssLoaderPath: require.resolve('css-loader'), - postCssLoaderPath: require.resolve('postcss-loader'), - postCssConfig - }; - - return [ - { - test: /\.m?js/, - resolve: { - fullySpecified: false - } - }, - { - // "oneOf" will traverse all following loaders until one will - // match the requirements. When no loader matches it will fall - // back to the "file" loader at the end of the loader list. - oneOf: [ - // MDX support - { - test: /\.md$/, - use: [ - { - loader: 'html-loader' - }, - { - loader: 'remark-loader', - options: { - removeFrontMatter: false, - remarkOptions: { - plugins: [RemarkPrism, RemarkHTML, RemarkFrontmatter] - } - } - } - ] - }, - // "postcss" loader applies autoprefixer to our CSS. - // "css" loader resolves paths in CSS and adds assets as dependencies. - // "style" loader turns CSS into JS modules that inject