@servicetitan/startup 22.17.0 → 22.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/build.d.ts +3 -2
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +1 -0
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/bundle-package.d.ts +2 -1
- package/dist/cli/commands/bundle-package.d.ts.map +1 -1
- package/dist/cli/commands/bundle-package.js +4 -3
- package/dist/cli/commands/bundle-package.js.map +1 -1
- package/dist/cli/commands/mfe-publish.d.ts +1 -0
- package/dist/cli/commands/mfe-publish.d.ts.map +1 -1
- package/dist/cli/commands/mfe-publish.js +3 -2
- package/dist/cli/commands/mfe-publish.js.map +1 -1
- package/dist/cli/commands/start.d.ts +3 -2
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +3 -2
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/utils/bundle.d.ts +7 -2
- package/dist/cli/utils/bundle.d.ts.map +1 -1
- package/dist/cli/utils/bundle.js +28 -58
- package/dist/cli/utils/bundle.js.map +1 -1
- package/dist/cli/utils/set-node-options.d.ts.map +1 -1
- package/dist/cli/utils/set-node-options.js +1 -1
- package/dist/cli/utils/set-node-options.js.map +1 -1
- package/dist/utils/debug.d.ts +5 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/dist/utils/debug.js +19 -0
- package/dist/utils/debug.js.map +1 -0
- package/dist/utils/get-configuration.d.ts +1 -0
- package/dist/utils/get-configuration.d.ts.map +1 -1
- package/dist/utils/get-configuration.js +6 -1
- package/dist/utils/get-configuration.js.map +1 -1
- package/dist/utils/log.d.ts +6 -0
- package/dist/utils/log.d.ts.map +1 -1
- package/dist/utils/log.js +22 -0
- package/dist/utils/log.js.map +1 -1
- package/dist/webpack/__mocks__/file-rules.d.ts +3 -0
- package/dist/webpack/__mocks__/file-rules.d.ts.map +1 -0
- package/dist/webpack/__mocks__/file-rules.js +31 -0
- package/dist/webpack/__mocks__/file-rules.js.map +1 -0
- package/dist/webpack/__mocks__/index.d.ts +3 -0
- package/dist/webpack/__mocks__/index.d.ts.map +1 -0
- package/dist/webpack/__mocks__/index.js +19 -0
- package/dist/webpack/__mocks__/index.js.map +1 -0
- package/dist/webpack/__mocks__/style-rules.d.ts +8 -0
- package/dist/webpack/__mocks__/style-rules.d.ts.map +1 -0
- package/dist/webpack/__mocks__/style-rules.js +124 -0
- package/dist/webpack/__mocks__/style-rules.js.map +1 -0
- package/dist/webpack/configs/cache-config.d.ts +6 -0
- package/dist/webpack/configs/cache-config.d.ts.map +1 -0
- package/dist/webpack/configs/cache-config.js +24 -0
- package/dist/webpack/configs/cache-config.js.map +1 -0
- package/dist/webpack/configs/dev-server-config.d.ts +6 -0
- package/dist/webpack/configs/dev-server-config.d.ts.map +1 -0
- package/dist/webpack/configs/dev-server-config.js +27 -0
- package/dist/webpack/configs/dev-server-config.js.map +1 -0
- package/dist/webpack/configs/devtool-config.d.ts +6 -0
- package/dist/webpack/configs/devtool-config.d.ts.map +1 -0
- package/dist/webpack/configs/devtool-config.js +16 -0
- package/dist/webpack/configs/devtool-config.js.map +1 -0
- package/dist/webpack/configs/entry.config.d.ts +6 -0
- package/dist/webpack/configs/entry.config.d.ts.map +1 -0
- package/dist/webpack/configs/entry.config.js +14 -0
- package/dist/webpack/configs/entry.config.js.map +1 -0
- package/dist/webpack/configs/externals-config.d.ts +6 -0
- package/dist/webpack/configs/externals-config.d.ts.map +1 -0
- package/dist/webpack/configs/externals-config.js +16 -0
- package/dist/webpack/configs/externals-config.js.map +1 -0
- package/dist/webpack/configs/index.d.ts +13 -0
- package/dist/webpack/configs/index.d.ts.map +1 -0
- package/dist/webpack/configs/index.js +29 -0
- package/dist/webpack/configs/index.js.map +1 -0
- package/dist/webpack/configs/loaders/css-loader.d.ts +14 -0
- package/dist/webpack/configs/loaders/css-loader.d.ts.map +1 -0
- package/dist/webpack/configs/loaders/css-loader.js +17 -0
- package/dist/webpack/configs/loaders/css-loader.js.map +1 -0
- package/dist/webpack/configs/loaders/index.d.ts +5 -0
- package/dist/webpack/configs/loaders/index.d.ts.map +1 -0
- package/dist/webpack/configs/loaders/index.js +21 -0
- package/dist/webpack/configs/loaders/index.js.map +1 -0
- package/dist/webpack/configs/loaders/less-loader.d.ts +9 -0
- package/dist/webpack/configs/loaders/less-loader.d.ts.map +1 -0
- package/dist/webpack/configs/loaders/less-loader.js +8 -0
- package/dist/webpack/configs/loaders/less-loader.js.map +1 -0
- package/dist/webpack/configs/loaders/style-loader.d.ts +9 -0
- package/dist/webpack/configs/loaders/style-loader.d.ts.map +1 -0
- package/dist/webpack/configs/loaders/style-loader.js +13 -0
- package/dist/webpack/configs/loaders/style-loader.js.map +1 -0
- package/dist/webpack/configs/loaders/types.d.ts +4 -0
- package/dist/webpack/configs/loaders/types.d.ts.map +1 -0
- package/dist/webpack/configs/loaders/types.js +3 -0
- package/dist/webpack/configs/loaders/types.js.map +1 -0
- package/dist/webpack/configs/module-config.d.ts +6 -0
- package/dist/webpack/configs/module-config.d.ts.map +1 -0
- package/dist/webpack/configs/module-config.js +10 -0
- package/dist/webpack/configs/module-config.js.map +1 -0
- package/dist/webpack/configs/optimization-config.d.ts +6 -0
- package/dist/webpack/configs/optimization-config.d.ts.map +1 -0
- package/dist/webpack/configs/optimization-config.js +57 -0
- package/dist/webpack/configs/optimization-config.js.map +1 -0
- package/dist/webpack/configs/output-config.d.ts +6 -0
- package/dist/webpack/configs/output-config.d.ts.map +1 -0
- package/dist/webpack/configs/output-config.js +23 -0
- package/dist/webpack/configs/output-config.js.map +1 -0
- package/dist/webpack/configs/plugins/assets-manifest-plugin.d.ts +4 -0
- package/dist/webpack/configs/plugins/assets-manifest-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/assets-manifest-plugin.js +34 -0
- package/dist/webpack/configs/plugins/assets-manifest-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.d.ts +3 -0
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.js +20 -0
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.d.ts +4 -0
- package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.js +25 -0
- package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/define-web-component-name-plugin.d.ts +4 -0
- package/dist/webpack/configs/plugins/define-web-component-name-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/define-web-component-name-plugin.js +16 -0
- package/dist/webpack/configs/plugins/define-web-component-name-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/filter-warnings-plugin.d.ts +3 -0
- package/dist/webpack/configs/plugins/filter-warnings-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/filter-warnings-plugin.js +14 -0
- package/dist/webpack/configs/plugins/filter-warnings-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/html-plugin.d.ts +4 -0
- package/dist/webpack/configs/plugins/html-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/html-plugin.js +42 -0
- package/dist/webpack/configs/plugins/html-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/index.d.ts +12 -0
- package/dist/webpack/configs/plugins/index.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/index.js +28 -0
- package/dist/webpack/configs/plugins/index.js.map +1 -0
- package/dist/webpack/configs/plugins/mini-css-extract-plugin.d.ts +4 -0
- package/dist/webpack/configs/plugins/mini-css-extract-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/mini-css-extract-plugin.js +23 -0
- package/dist/webpack/configs/plugins/mini-css-extract-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/moment-locales-plugin.d.ts +4 -0
- package/dist/webpack/configs/plugins/moment-locales-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/moment-locales-plugin.js +14 -0
- package/dist/webpack/configs/plugins/moment-locales-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/provide-react-plugin.d.ts +4 -0
- package/dist/webpack/configs/plugins/provide-react-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/provide-react-plugin.js +14 -0
- package/dist/webpack/configs/plugins/provide-react-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/ts-checker-plugin.d.ts +4 -0
- package/dist/webpack/configs/plugins/ts-checker-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/ts-checker-plugin.js +31 -0
- package/dist/webpack/configs/plugins/ts-checker-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/virtual-modules-plugin.d.ts +4 -0
- package/dist/webpack/configs/plugins/virtual-modules-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/virtual-modules-plugin.js +42 -0
- package/dist/webpack/configs/plugins/virtual-modules-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins-config.d.ts +6 -0
- package/dist/webpack/configs/plugins-config.d.ts.map +1 -0
- package/dist/webpack/configs/plugins-config.js +24 -0
- package/dist/webpack/configs/plugins-config.js.map +1 -0
- package/dist/webpack/configs/resolve-config.d.ts +6 -0
- package/dist/webpack/configs/resolve-config.d.ts.map +1 -0
- package/dist/webpack/configs/resolve-config.js +11 -0
- package/dist/webpack/configs/resolve-config.js.map +1 -0
- package/dist/webpack/configs/rules/css-rules.d.ts +4 -0
- package/dist/webpack/configs/rules/css-rules.d.ts.map +1 -0
- package/dist/webpack/configs/rules/css-rules.js +35 -0
- package/dist/webpack/configs/rules/css-rules.js.map +1 -0
- package/dist/webpack/configs/rules/font-rules.d.ts +4 -0
- package/dist/webpack/configs/rules/font-rules.d.ts.map +1 -0
- package/dist/webpack/configs/rules/font-rules.js +16 -0
- package/dist/webpack/configs/rules/font-rules.js.map +1 -0
- package/dist/webpack/configs/rules/image-rules.d.ts +4 -0
- package/dist/webpack/configs/rules/image-rules.d.ts.map +1 -0
- package/dist/webpack/configs/rules/image-rules.js +16 -0
- package/dist/webpack/configs/rules/image-rules.js.map +1 -0
- package/dist/webpack/configs/rules/index.d.ts +8 -0
- package/dist/webpack/configs/rules/index.d.ts.map +1 -0
- package/dist/webpack/configs/rules/index.js +24 -0
- package/dist/webpack/configs/rules/index.js.map +1 -0
- package/dist/webpack/configs/rules/js-rules.d.ts +4 -0
- package/dist/webpack/configs/rules/js-rules.d.ts.map +1 -0
- package/dist/webpack/configs/rules/js-rules.js +19 -0
- package/dist/webpack/configs/rules/js-rules.js.map +1 -0
- package/dist/webpack/configs/rules/less-rules.d.ts +4 -0
- package/dist/webpack/configs/rules/less-rules.d.ts.map +1 -0
- package/dist/webpack/configs/rules/less-rules.js +23 -0
- package/dist/webpack/configs/rules/less-rules.js.map +1 -0
- package/dist/webpack/configs/rules/scss-rules.d.ts +4 -0
- package/dist/webpack/configs/rules/scss-rules.d.ts.map +1 -0
- package/dist/webpack/configs/rules/scss-rules.js +23 -0
- package/dist/webpack/configs/rules/scss-rules.js.map +1 -0
- package/dist/webpack/configs/rules/tsx-rules.d.ts +4 -0
- package/dist/webpack/configs/rules/tsx-rules.d.ts.map +1 -0
- package/dist/webpack/configs/rules/tsx-rules.js +23 -0
- package/dist/webpack/configs/rules/tsx-rules.js.map +1 -0
- package/dist/webpack/configs/rules-config.d.ts +9 -0
- package/dist/webpack/configs/rules-config.d.ts.map +1 -0
- package/dist/webpack/configs/rules-config.js +31 -0
- package/dist/webpack/configs/rules-config.js.map +1 -0
- package/dist/webpack/configs/stats-config.d.ts +6 -0
- package/dist/webpack/configs/stats-config.d.ts.map +1 -0
- package/dist/webpack/configs/stats-config.js +16 -0
- package/dist/webpack/configs/stats-config.js.map +1 -0
- package/dist/webpack/configs/types.d.ts +15 -0
- package/dist/webpack/configs/types.d.ts.map +1 -0
- package/dist/webpack/configs/types.js +3 -0
- package/dist/webpack/configs/types.js.map +1 -0
- package/dist/webpack/configs/utils/generate-metadata.d.ts +3 -0
- package/dist/webpack/configs/utils/generate-metadata.d.ts.map +1 -0
- package/dist/webpack/configs/utils/generate-metadata.js +31 -0
- package/dist/webpack/configs/utils/generate-metadata.js.map +1 -0
- package/dist/webpack/configs/utils/get-startup-version.d.ts +2 -0
- package/dist/webpack/configs/utils/get-startup-version.d.ts.map +1 -0
- package/dist/webpack/configs/utils/get-startup-version.js +13 -0
- package/dist/webpack/configs/utils/get-startup-version.js.map +1 -0
- package/dist/webpack/configs/utils/index.d.ts +2 -0
- package/dist/webpack/configs/utils/index.d.ts.map +1 -0
- package/dist/webpack/configs/utils/index.js +18 -0
- package/dist/webpack/configs/utils/index.js.map +1 -0
- package/dist/webpack/create-webpack-config.d.ts +4 -0
- package/dist/webpack/create-webpack-config.d.ts.map +1 -0
- package/dist/webpack/create-webpack-config.js +67 -0
- package/dist/webpack/create-webpack-config.js.map +1 -0
- package/dist/webpack/index.d.ts +2 -10
- package/dist/webpack/index.d.ts.map +1 -1
- package/dist/webpack/index.js +16 -21
- package/dist/webpack/index.js.map +1 -1
- package/dist/webpack/types.d.ts +18 -0
- package/dist/webpack/types.d.ts.map +1 -0
- package/dist/webpack/types.js +3 -0
- package/dist/webpack/types.js.map +1 -0
- package/dist/webpack/utils/index.d.ts +5 -0
- package/dist/webpack/utils/index.d.ts.map +1 -0
- package/dist/webpack/utils/index.js +21 -0
- package/dist/webpack/utils/index.js.map +1 -0
- package/package.json +5 -4
- package/src/cli/commands/__tests__/build.test.ts +13 -0
- package/src/cli/commands/__tests__/bundle-package.test.ts +27 -4
- package/src/cli/commands/__tests__/mfe-package-publish.test.ts +10 -0
- package/src/cli/commands/__tests__/mfe-publish.test.ts +1 -0
- package/src/cli/commands/__tests__/start.test.ts +15 -0
- package/src/cli/commands/build.ts +4 -2
- package/src/cli/commands/bundle-package.ts +7 -4
- package/src/cli/commands/mfe-publish.ts +3 -1
- package/src/cli/commands/start.ts +6 -4
- package/src/cli/utils/__tests__/bundle.test.ts +142 -111
- package/src/cli/utils/__tests__/set-node-options.test.ts +4 -4
- package/src/cli/utils/bundle.ts +37 -118
- package/src/cli/utils/set-node-options.ts +2 -2
- package/src/utils/__tests__/get-configuration.test.ts +46 -0
- package/src/utils/__tests__/log.test.ts +43 -1
- package/src/utils/debug.ts +13 -0
- package/src/utils/get-configuration.ts +5 -1
- package/src/utils/log.ts +22 -0
- package/src/webpack/__mocks__/file-rules.ts +29 -0
- package/src/webpack/__mocks__/index.ts +2 -0
- package/src/webpack/__mocks__/style-rules.ts +126 -0
- package/src/webpack/__tests__/create-webpack-config-shared-dependencies.test.ts +162 -0
- package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +331 -0
- package/src/webpack/__tests__/create-webpack-config.test.ts +400 -42
- package/src/webpack/configs/cache-config.ts +25 -0
- package/src/webpack/configs/dev-server-config.ts +43 -0
- package/src/webpack/configs/devtool-config.ts +18 -0
- package/src/webpack/configs/entry.config.ts +18 -0
- package/src/webpack/configs/externals-config.ts +21 -0
- package/src/webpack/configs/index.ts +12 -0
- package/src/webpack/configs/loaders/css-loader.ts +19 -0
- package/src/webpack/configs/loaders/index.ts +4 -0
- package/src/webpack/configs/loaders/less-loader.ts +3 -0
- package/src/webpack/configs/loaders/style-loader.ts +11 -0
- package/src/webpack/configs/loaders/types.ts +3 -0
- package/src/webpack/configs/module-config.ts +12 -0
- package/src/webpack/configs/optimization-config.ts +63 -0
- package/src/webpack/configs/output-config.ts +28 -0
- package/src/webpack/configs/plugins/assets-manifest-plugin.ts +34 -0
- package/src/webpack/configs/plugins/bundle-analyser-plugin.ts +18 -0
- package/src/webpack/configs/plugins/define-exposed-dependencies-plugin.ts +29 -0
- package/src/webpack/configs/plugins/define-web-component-name-plugin.ts +14 -0
- package/src/webpack/configs/plugins/filter-warnings-plugin.ts +12 -0
- package/src/webpack/configs/plugins/html-plugin.ts +53 -0
- package/src/webpack/configs/plugins/index.ts +11 -0
- package/src/webpack/configs/plugins/mini-css-extract-plugin.ts +19 -0
- package/src/webpack/configs/plugins/moment-locales-plugin.ts +8 -0
- package/src/webpack/configs/plugins/provide-react-plugin.ts +12 -0
- package/src/webpack/configs/plugins/ts-checker-plugin.ts +33 -0
- package/src/webpack/configs/plugins/virtual-modules-plugin.ts +42 -0
- package/src/webpack/configs/plugins-config.ts +38 -0
- package/src/webpack/configs/resolve-config.ts +13 -0
- package/src/webpack/configs/rules/css-rules.ts +36 -0
- package/src/webpack/configs/rules/font-rules.ts +14 -0
- package/src/webpack/configs/rules/image-rules.ts +14 -0
- package/src/webpack/configs/rules/index.ts +7 -0
- package/src/webpack/configs/rules/js-rules.ts +17 -0
- package/src/webpack/configs/rules/less-rules.ts +21 -0
- package/src/webpack/configs/rules/scss-rules.ts +21 -0
- package/src/webpack/configs/rules/tsx-rules.ts +22 -0
- package/src/webpack/configs/rules-config.ts +38 -0
- package/src/webpack/configs/stats-config.ts +18 -0
- package/src/webpack/configs/types.ts +15 -0
- package/src/webpack/configs/utils/__tests__/generate-metadata.test.ts +77 -0
- package/src/webpack/configs/utils/__tests__/get-startup-version.test.ts +27 -0
- package/src/webpack/configs/utils/generate-metadata.ts +30 -0
- package/src/webpack/configs/utils/get-startup-version.ts +8 -0
- package/src/webpack/configs/utils/index.ts +1 -0
- package/src/webpack/create-webpack-config.ts +110 -0
- package/src/webpack/index.ts +2 -52
- package/{dist/webpack/shared.config.d.ts → src/webpack/types.ts} +10 -4
- package/src/webpack/utils/index.ts +4 -0
- package/dist/webpack/development.config.d.ts +0 -11
- package/dist/webpack/development.config.d.ts.map +0 -1
- package/dist/webpack/development.config.js +0 -191
- package/dist/webpack/development.config.js.map +0 -1
- package/dist/webpack/production.config.d.ts +0 -14
- package/dist/webpack/production.config.d.ts.map +0 -1
- package/dist/webpack/production.config.js +0 -172
- package/dist/webpack/production.config.js.map +0 -1
- package/dist/webpack/shared.config.d.ts.map +0 -1
- package/dist/webpack/shared.config.js +0 -268
- package/dist/webpack/shared.config.js.map +0 -1
- package/src/webpack/__tests__/create-development-config.test.ts +0 -306
- package/src/webpack/__tests__/create-production-config.test.ts +0 -231
- package/src/webpack/__tests__/create-shared-config.test.ts +0 -508
- package/src/webpack/development.config.ts +0 -237
- package/src/webpack/production.config.ts +0 -197
- package/src/webpack/shared.config.ts +0 -360
|
@@ -1,74 +1,432 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
|
|
2
|
+
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
3
|
+
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
4
|
+
import mockFS from 'mock-fs';
|
|
5
|
+
import MomentLocalesPlugin from 'moment-locales-webpack-plugin';
|
|
6
|
+
import os from 'os';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { ProvidePlugin } from 'webpack';
|
|
9
|
+
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
10
|
+
const FilterWarningsPlugin = require('webpack-filter-warnings-plugin');
|
|
11
|
+
import { argv } from 'yargs';
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
Package,
|
|
15
|
+
PackageType,
|
|
16
|
+
getFolders,
|
|
17
|
+
getPackageData,
|
|
18
|
+
getPackageDependencyVersion,
|
|
19
|
+
getPackages,
|
|
20
|
+
getTsConfig,
|
|
21
|
+
isCustomStyleRules,
|
|
22
|
+
isWebComponent,
|
|
23
|
+
loadSharedDependencies,
|
|
24
|
+
} from '../../utils';
|
|
25
|
+
import { createPackage } from '../../__mocks__';
|
|
26
|
+
import { fileRules, productionStyleRules, styleRules } from '../__mocks__';
|
|
27
|
+
import { featureCohort, splitByEntry } from '../utils';
|
|
7
28
|
|
|
8
29
|
import { createWebpackConfig } from '../index';
|
|
9
30
|
|
|
31
|
+
jest.mock('fork-ts-checker-webpack-plugin', () => jest.fn());
|
|
32
|
+
jest.mock('html-webpack-plugin', () => jest.fn());
|
|
33
|
+
jest.mock('mini-css-extract-plugin', () =>
|
|
34
|
+
Object.assign(jest.fn(), { loader: 'MiniCssExtractPlugin.loader' })
|
|
35
|
+
);
|
|
36
|
+
jest.mock('moment-locales-webpack-plugin', () => jest.fn());
|
|
37
|
+
jest.mock('webpack', () => ({
|
|
38
|
+
...jest.requireActual('webpack'),
|
|
39
|
+
ProvidePlugin: jest.fn(),
|
|
40
|
+
}));
|
|
41
|
+
jest.mock('webpack-assets-manifest', () => jest.fn());
|
|
42
|
+
jest.mock('webpack-bundle-analyzer', () => ({ BundleAnalyzerPlugin: jest.fn() }));
|
|
43
|
+
jest.mock('webpack-filter-warnings-plugin', () => jest.fn());
|
|
44
|
+
jest.mock('webpack-virtual-modules', () => jest.fn());
|
|
45
|
+
jest.mock('yargs', () => ({ argv: {} }));
|
|
10
46
|
jest.mock('../../utils', () => ({
|
|
11
47
|
...jest.requireActual('../../utils'),
|
|
48
|
+
getFolders: jest.fn(),
|
|
49
|
+
getPackageData: jest.fn(),
|
|
50
|
+
getPackageDependencyVersion: jest.fn(),
|
|
51
|
+
getPackages: jest.fn(),
|
|
52
|
+
getTsConfig: jest.fn(),
|
|
53
|
+
isCustomStyleRules: jest.fn(),
|
|
54
|
+
isExposeSharedDependencies: jest.fn(),
|
|
12
55
|
isWebComponent: jest.fn(),
|
|
56
|
+
loadSharedDependencies: jest.fn(),
|
|
57
|
+
log: { debug: jest.fn(), info: jest.fn() },
|
|
58
|
+
}));
|
|
59
|
+
jest.mock('../utils', () => ({
|
|
60
|
+
...jest.requireActual('../utils'),
|
|
61
|
+
featureCohort: jest.fn(),
|
|
13
62
|
}));
|
|
14
|
-
jest.mock('../development.config');
|
|
15
|
-
jest.mock('../production.config');
|
|
16
|
-
jest.mock('../utils/get-caller-filename');
|
|
17
63
|
|
|
18
|
-
describe(
|
|
19
|
-
const
|
|
20
|
-
const
|
|
64
|
+
describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
65
|
+
const source = 'src';
|
|
66
|
+
const destination = 'dist';
|
|
67
|
+
const packageName = '@servicetitan/foo';
|
|
68
|
+
const packageJson = 'package.json';
|
|
69
|
+
const tsConfig = 'tsconfig.build.json';
|
|
70
|
+
const sharedDependencies = {
|
|
71
|
+
'@servicetitan/design-system': 'SharedDependencies.ServiceTitan.DesignSystem',
|
|
72
|
+
'react': 'SharedDependencies.React',
|
|
73
|
+
};
|
|
74
|
+
const dependencies: Record<string, string> = {
|
|
75
|
+
'@servicetitan/design-system': '1.2.3',
|
|
76
|
+
'react': '4.5.6',
|
|
77
|
+
};
|
|
21
78
|
|
|
79
|
+
let packages: Package[];
|
|
22
80
|
let overrides: Parameters<typeof createWebpackConfig>[0];
|
|
23
81
|
let options: Parameters<typeof createWebpackConfig>[1];
|
|
24
82
|
|
|
83
|
+
function mockPlugIn(name: string) {
|
|
84
|
+
return (options: Record<string, any>): any => ({ [name]: options });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function setOptions(props: typeof options) {
|
|
88
|
+
Object.assign((options ??= {}), props);
|
|
89
|
+
}
|
|
90
|
+
|
|
25
91
|
beforeEach(() => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
92
|
+
packages = [];
|
|
93
|
+
overrides = {
|
|
94
|
+
plugins: {
|
|
95
|
+
ForkTsCheckerWebpackPlugin: { logger: 'webpack-infrastructure' },
|
|
96
|
+
HtmlWebpackPlugin: { favicon: 'foo' },
|
|
97
|
+
MiniCssExtractPlugin: { attributes: { foo: 'bar' } },
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
options = undefined;
|
|
101
|
+
|
|
102
|
+
jest.resetAllMocks();
|
|
103
|
+
jest.mocked(MiniCssExtractPlugin).mockImplementation(mockPlugIn('MiniCssExtractPlugin'));
|
|
104
|
+
jest.mocked(BundleAnalyzerPlugin).mockImplementation(mockPlugIn('BundleAnalyzerPlugin'));
|
|
105
|
+
jest.mocked(FilterWarningsPlugin).mockImplementation(mockPlugIn('FilterWarningsPlugin'));
|
|
106
|
+
jest.mocked(ForkTsCheckerWebpackPlugin).mockImplementation(
|
|
107
|
+
mockPlugIn('ForkTsCheckerWebpackPlugin')
|
|
108
|
+
);
|
|
109
|
+
jest.mocked(HtmlWebpackPlugin).mockImplementation(mockPlugIn('HtmlWebpackPlugin'));
|
|
110
|
+
jest.mocked(MomentLocalesPlugin).mockImplementation(mockPlugIn('MomentLocalesPlugin'));
|
|
111
|
+
jest.mocked(ProvidePlugin).mockImplementation(mockPlugIn('ProvidePlugin'));
|
|
112
|
+
|
|
113
|
+
jest.mocked(getFolders).mockImplementation((location?: string) => ({
|
|
114
|
+
source: `${location ? `${location.replace(/\W/g, '')}-` : ''}${source}`,
|
|
115
|
+
destination,
|
|
116
|
+
}));
|
|
117
|
+
jest.mocked(getPackageData).mockReturnValue({ dependencies, sharedDependencies });
|
|
118
|
+
jest.mocked(getPackageDependencyVersion).mockImplementation(
|
|
119
|
+
(_, defaultVersion) => defaultVersion
|
|
120
|
+
);
|
|
121
|
+
jest.mocked(getPackages).mockImplementation(() => packages);
|
|
122
|
+
jest.mocked(getTsConfig).mockReturnValue(tsConfig);
|
|
123
|
+
jest.mocked(loadSharedDependencies).mockReturnValue(sharedDependencies);
|
|
124
|
+
|
|
125
|
+
Object.keys(argv).forEach(key => delete (argv as any)[key]);
|
|
126
|
+
|
|
127
|
+
mockFS({ [packageJson]: JSON.stringify({ name: packageName }) });
|
|
30
128
|
});
|
|
31
129
|
|
|
130
|
+
afterEach(() => mockFS.restore());
|
|
131
|
+
|
|
32
132
|
const subject = () => createWebpackConfig(overrides, options);
|
|
33
133
|
|
|
34
|
-
|
|
35
|
-
|
|
134
|
+
test('configures "entry"', () => {
|
|
135
|
+
expect(subject().entry).toEqual({ main: [`./${source}/index`] });
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test('configures "resolve"', () => {
|
|
139
|
+
expect(subject().resolve).toEqual({ extensions: ['.js', '.jsx', '.ts', '.tsx'] });
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test('configures "devtool"', () => {
|
|
143
|
+
expect(subject().devtool).toEqual('cheap-module-source-map');
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test('configures "output.filename"', () => {
|
|
147
|
+
expect(subject().output?.filename).toEqual('[name].bundle.js');
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test('configures "output.path"', () => {
|
|
151
|
+
expect(subject().output!.path).toEqual(
|
|
152
|
+
expect.stringContaining(path.join(destination, 'bundle'))
|
|
153
|
+
);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test('configures "optimization"', () => {
|
|
157
|
+
expect(subject().optimization).toEqual({
|
|
158
|
+
chunkIds: 'size',
|
|
159
|
+
moduleIds: 'size',
|
|
160
|
+
mangleExports: 'size',
|
|
161
|
+
splitChunks: { cacheGroups: {} },
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
test('configures "stats"', () => {
|
|
166
|
+
expect(subject().stats).toEqual({
|
|
167
|
+
all: false,
|
|
168
|
+
errors: true,
|
|
169
|
+
errorDetails: true,
|
|
170
|
+
warnings: true,
|
|
171
|
+
builtAt: true,
|
|
172
|
+
colors: true,
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test('configures "devServer"', () => {
|
|
177
|
+
expect(subject().devServer).toEqual({
|
|
178
|
+
port: 8080,
|
|
179
|
+
historyApiFallback: true,
|
|
180
|
+
writeToDisk: true,
|
|
181
|
+
headers: {
|
|
182
|
+
'Access-Control-Allow-Origin': '*',
|
|
183
|
+
'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept',
|
|
184
|
+
},
|
|
185
|
+
stats: expect.anything(),
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
describe('with configuration overrides', () => {
|
|
190
|
+
beforeEach(() => (overrides.configuration = { devtool: 'eval' }));
|
|
191
|
+
|
|
192
|
+
test('includes input configuration', () => {
|
|
193
|
+
expect(subject()).toEqual(expect.objectContaining(overrides.configuration));
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
describe('with subordinate TSC packages', () => {
|
|
198
|
+
beforeEach(() => {
|
|
199
|
+
packages = [
|
|
200
|
+
createPackage({ name: 'bar', type: PackageType.TSC }),
|
|
201
|
+
createPackage({ name: 'baz', type: PackageType.Webpack }),
|
|
202
|
+
];
|
|
203
|
+
});
|
|
36
204
|
|
|
37
|
-
test('
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
205
|
+
test('configures "devServer.watchOptions" to ignore TSC packages', () => {
|
|
206
|
+
const ignored = packages
|
|
207
|
+
.filter(({ type }) => type === PackageType.TSC)
|
|
208
|
+
.map(({ location }) => path.join(location, getFolders(location).source));
|
|
209
|
+
expect(subject().devServer?.watchOptions).toEqual({ ignored });
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
Object.entries({ ...fileRules, ...styleRules }).forEach(([extension, rule]) => {
|
|
214
|
+
test(`configures "${extension}" rules`, () => {
|
|
215
|
+
expect(subject().module?.rules).toContainEqual(rule);
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
describe('when package has custom style rules', () => {
|
|
220
|
+
beforeEach(() => jest.mocked(isCustomStyleRules).mockReturnValue(true));
|
|
221
|
+
|
|
222
|
+
Object.entries(styleRules).forEach(([extension, rule]) => {
|
|
223
|
+
test(`omits "${extension}" rules`, () => {
|
|
224
|
+
expect(subject().module?.rules).not.toContainEqual(rule);
|
|
43
225
|
});
|
|
44
226
|
});
|
|
45
227
|
});
|
|
46
228
|
|
|
47
|
-
describe('
|
|
48
|
-
beforeEach(() => (
|
|
49
|
-
|
|
50
|
-
test('
|
|
51
|
-
expect(subject()).
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
229
|
+
describe('with --esbuild command line argument', () => {
|
|
230
|
+
beforeEach(() => Object.assign(argv, { esbuild: true }));
|
|
231
|
+
|
|
232
|
+
test('configures ".tsx" rules to use esbuild-loader', () => {
|
|
233
|
+
expect(subject().module?.rules).toContainEqual({
|
|
234
|
+
test: /\.tsx?$/,
|
|
235
|
+
exclude: /node_modules/,
|
|
236
|
+
use: [
|
|
237
|
+
{
|
|
238
|
+
loader: 'esbuild-loader',
|
|
239
|
+
options: { loader: 'tsx', target: 'es2018' },
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
test('configures React to load automatically', () => {
|
|
246
|
+
expect(subject().plugins).toContainEqual(new ProvidePlugin({ React: 'react' }));
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
test('configures ".css" rule to exclude .module.css files', () => {
|
|
251
|
+
const cssRule: any = subject().module?.rules?.find(({ test }: { test: RegExp }) =>
|
|
252
|
+
'.css'.match(test)
|
|
253
|
+
);
|
|
254
|
+
expect(
|
|
255
|
+
['design-system.css', 'foo.module.css', 'foo.css'].filter(path => cssRule.exclude(path))
|
|
256
|
+
).toEqual(['foo.module.css']);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
test('configures MomentLocalesPlugin plugin', () => {
|
|
260
|
+
expect(subject().plugins).toContainEqual(
|
|
261
|
+
new MomentLocalesPlugin({ localesToKeep: ['en-au', 'en-ca', 'en-gb'] })
|
|
262
|
+
);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
test('configures ForkTsCheckerWebpackPlugin plugin', () => {
|
|
266
|
+
expect(subject().plugins).toContainEqual(
|
|
267
|
+
new ForkTsCheckerWebpackPlugin({
|
|
268
|
+
typescript: {
|
|
269
|
+
configFile: tsConfig,
|
|
270
|
+
configOverwrite: {
|
|
271
|
+
exclude: [
|
|
272
|
+
'**/__tests__/**/*',
|
|
273
|
+
'**/__mocks__/**/*',
|
|
274
|
+
'**/*.test.*',
|
|
275
|
+
'**/*.stories.tsx',
|
|
276
|
+
],
|
|
277
|
+
references: [],
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
...overrides.plugins?.ForkTsCheckerWebpackPlugin,
|
|
281
|
+
})
|
|
282
|
+
);
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
test('configures FilterWarningsPlugin plugin', () => {
|
|
286
|
+
expect(subject().plugins).toContainEqual(
|
|
287
|
+
new FilterWarningsPlugin({
|
|
288
|
+
exclude: /export .* was not found in/,
|
|
289
|
+
})
|
|
290
|
+
);
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
test('configures HtmlWebpackPlugin plugin', () => {
|
|
294
|
+
expect(subject().plugins).toContainEqual(
|
|
295
|
+
new HtmlWebpackPlugin({
|
|
296
|
+
title: 'ServiceTitan',
|
|
297
|
+
hash: true,
|
|
298
|
+
templateParameters: { splitByEntry },
|
|
299
|
+
...overrides.plugins?.HtmlWebpackPlugin,
|
|
300
|
+
})
|
|
301
|
+
);
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
describe('when buildStat option is set to true', () => {
|
|
305
|
+
beforeEach(() => {
|
|
306
|
+
setOptions({ buildStat: true });
|
|
307
|
+
jest.useFakeTimers(); // because filename includes timestamp
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
const reportFilename = (type: string) =>
|
|
311
|
+
path.join(os.tmpdir(), `report-${type}-bundle-${Date.now()}.html`);
|
|
312
|
+
|
|
313
|
+
test('configures BundleAnalyzerPlugin plugin', () => {
|
|
314
|
+
expect(subject().plugins).toContainEqual(
|
|
315
|
+
new BundleAnalyzerPlugin({
|
|
316
|
+
analyzerMode: 'static',
|
|
317
|
+
reportFilename: reportFilename('full'),
|
|
318
|
+
})
|
|
319
|
+
);
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
describe('when embed option is set to true', () => {
|
|
323
|
+
beforeEach(() => setOptions({ embed: true }));
|
|
324
|
+
|
|
325
|
+
test('changes BundleAnalyzerPlugin reportFilename from "full" to "light"', () => {
|
|
326
|
+
expect(subject().plugins).toContainEqual(
|
|
327
|
+
new BundleAnalyzerPlugin({
|
|
328
|
+
analyzerMode: 'static',
|
|
329
|
+
reportFilename: reportFilename('light'),
|
|
330
|
+
})
|
|
331
|
+
);
|
|
56
332
|
});
|
|
57
333
|
});
|
|
58
334
|
});
|
|
59
335
|
|
|
60
|
-
describe('when
|
|
61
|
-
beforeEach(() =>
|
|
336
|
+
describe('when embed option is set to true', () => {
|
|
337
|
+
beforeEach(() => setOptions({ embed: true, name: packageName }));
|
|
338
|
+
|
|
339
|
+
test('configures "externals"', () => {
|
|
340
|
+
expect(subject().externals).toEqual(
|
|
341
|
+
Object.fromEntries(
|
|
342
|
+
Object.entries(sharedDependencies).map(([name, value]) => [
|
|
343
|
+
name,
|
|
344
|
+
`${value}['${options!.name}']`,
|
|
345
|
+
])
|
|
346
|
+
)
|
|
347
|
+
);
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
describe('when featureCohort is active', () => {
|
|
352
|
+
beforeEach(() => {
|
|
353
|
+
jest.mocked(featureCohort).mockImplementation((_: number[], fn: Function) => fn());
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
test('configures "cache"', () => {
|
|
357
|
+
expect(subject().cache).toEqual({
|
|
358
|
+
type: 'filesystem',
|
|
359
|
+
name: packageName,
|
|
360
|
+
profile: true,
|
|
361
|
+
});
|
|
362
|
+
});
|
|
62
363
|
|
|
63
|
-
describe
|
|
64
|
-
|
|
65
|
-
configFileName => {
|
|
66
|
-
beforeEach(() => jest.mocked(getCallerFile).mockReturnValue(configFileName));
|
|
364
|
+
describe('when package is web component', () => {
|
|
365
|
+
beforeEach(() => jest.mocked(isWebComponent).mockReturnValue(true));
|
|
67
366
|
|
|
68
|
-
|
|
69
|
-
|
|
367
|
+
function itAppendsSuffixToPackageName(suffix: string) {
|
|
368
|
+
test(`appends "${suffix}" to package name`, () => {
|
|
369
|
+
expect(subject().cache).toEqual(
|
|
370
|
+
expect.objectContaining({
|
|
371
|
+
name: `${packageName}${suffix}`,
|
|
372
|
+
})
|
|
373
|
+
);
|
|
70
374
|
});
|
|
71
375
|
}
|
|
72
|
-
|
|
376
|
+
|
|
377
|
+
itAppendsSuffixToPackageName('__full');
|
|
378
|
+
|
|
379
|
+
describe('when embed option is set to true', () => {
|
|
380
|
+
beforeEach(() => setOptions({ embed: true }));
|
|
381
|
+
|
|
382
|
+
itAppendsSuffixToPackageName('__light');
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
describe('when mode is "production"', () => {
|
|
388
|
+
beforeEach(() => Object.assign((overrides.configuration ??= {}), { mode: 'production' }));
|
|
389
|
+
|
|
390
|
+
test('changes "devtool" to "source-map"', () => {
|
|
391
|
+
expect(subject().devtool).toEqual('source-map');
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
test('configures MiniCssExtractPlugin plugin', () => {
|
|
395
|
+
expect(subject().plugins).toContainEqual(
|
|
396
|
+
new MiniCssExtractPlugin({
|
|
397
|
+
filename: '[name].[contenthash:8].bundle.css',
|
|
398
|
+
...overrides.plugins?.MiniCssExtractPlugin,
|
|
399
|
+
})
|
|
400
|
+
);
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
test('changes "output.filename"', () => {
|
|
404
|
+
expect(subject().output?.filename).toBe('[name].[contenthash:8].bundle.js');
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
test('configures "output.clean"', () => {
|
|
408
|
+
expect(subject().output?.clean).toBe(true);
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
test('configures "optimization.runtimeChunk"', () => {
|
|
412
|
+
expect(subject().optimization?.runtimeChunk).toBe('single');
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
Object.entries(productionStyleRules).forEach(([extension, rules]) => {
|
|
416
|
+
test(`configures "${extension}" rules`, () => {
|
|
417
|
+
expect(subject().module?.rules).toContainEqual(rules);
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
describe('with process.env.CLIENT_CDN_PATH', () => {
|
|
422
|
+
const cdnPath = 'http://www.example.com/cdn';
|
|
423
|
+
|
|
424
|
+
beforeEach(() => (process.env.CLIENT_CDN_PATH = cdnPath));
|
|
425
|
+
afterEach(() => delete process.env.CLIENT_CDN_PATH);
|
|
426
|
+
|
|
427
|
+
test('configures "output.publicPath"', () => {
|
|
428
|
+
expect(subject().output?.publicPath).toEqual(cdnPath);
|
|
429
|
+
});
|
|
430
|
+
});
|
|
73
431
|
});
|
|
74
432
|
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Configuration } from 'webpack';
|
|
2
|
+
import { getPackageName, log } from '../../utils';
|
|
3
|
+
import { featureCohort } from '../utils';
|
|
4
|
+
import { Context, Overrides } from './types';
|
|
5
|
+
|
|
6
|
+
type Result = Pick<Configuration, 'cache'> | undefined;
|
|
7
|
+
|
|
8
|
+
export function cacheConfig(context: Context, _: Overrides): Result {
|
|
9
|
+
const { embed, isProduction, isWebComponent } = context;
|
|
10
|
+
if (isProduction) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return featureCohort([2, 5], () => {
|
|
15
|
+
const packageName = getPackageName();
|
|
16
|
+
log.info('Persistent cache is active');
|
|
17
|
+
return {
|
|
18
|
+
cache: {
|
|
19
|
+
type: 'filesystem',
|
|
20
|
+
name: isWebComponent ? `${packageName}__${embed ? 'light' : 'full'}` : packageName,
|
|
21
|
+
profile: true,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { Configuration } from 'webpack';
|
|
3
|
+
import {
|
|
4
|
+
PackageType,
|
|
5
|
+
getDevServerConfiguration,
|
|
6
|
+
getFolders,
|
|
7
|
+
getPackageName,
|
|
8
|
+
getPackages,
|
|
9
|
+
} from '../../utils';
|
|
10
|
+
import { statsConfig } from './stats-config';
|
|
11
|
+
import { Context, Overrides } from './types';
|
|
12
|
+
|
|
13
|
+
type Config = Configuration['devServer'];
|
|
14
|
+
type Result = Pick<Configuration, 'devServer'> | undefined;
|
|
15
|
+
|
|
16
|
+
export function devServerConfig(context: Context, overrides: Overrides): Result {
|
|
17
|
+
if (context.isProduction) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const devServer: Config = {
|
|
22
|
+
port: 8080,
|
|
23
|
+
historyApiFallback: true,
|
|
24
|
+
writeToDisk: true,
|
|
25
|
+
headers: {
|
|
26
|
+
'Access-Control-Allow-Origin': '*',
|
|
27
|
+
'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept',
|
|
28
|
+
},
|
|
29
|
+
...watchOptionsConfig(),
|
|
30
|
+
...statsConfig(context, overrides),
|
|
31
|
+
...getDevServerConfiguration(),
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return { devServer };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function watchOptionsConfig() {
|
|
38
|
+
const watchIgnore = getPackages({ scope: getPackageName() })
|
|
39
|
+
.filter(({ type }) => type === PackageType.TSC)
|
|
40
|
+
.map(({ location }) => path.join(location, getFolders(location).source));
|
|
41
|
+
|
|
42
|
+
return watchIgnore.length ? { watchOptions: { ignored: watchIgnore } } : undefined;
|
|
43
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Configuration } from 'webpack';
|
|
2
|
+
import { Context, Overrides } from './types';
|
|
3
|
+
|
|
4
|
+
type Config = Configuration['devtool'];
|
|
5
|
+
type Result = Pick<Configuration, 'devtool'>;
|
|
6
|
+
|
|
7
|
+
export function devtoolConfig(context: Context, _: Overrides): Result {
|
|
8
|
+
const { isProduction, isWebComponent } = context;
|
|
9
|
+
let devtool: Config;
|
|
10
|
+
|
|
11
|
+
if (isProduction) {
|
|
12
|
+
devtool = isWebComponent ? false : 'source-map';
|
|
13
|
+
} else {
|
|
14
|
+
devtool = 'cheap-module-source-map';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return { devtool };
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Configuration } from 'webpack';
|
|
2
|
+
import { getModuleEntryPath } from '../utils';
|
|
3
|
+
import { Context, Overrides } from './types';
|
|
4
|
+
|
|
5
|
+
type Config = Configuration['entry'];
|
|
6
|
+
type Result = Pick<Configuration, 'entry'>;
|
|
7
|
+
|
|
8
|
+
export function entryConfig(context: Context, _: Overrides): Result {
|
|
9
|
+
const { isExposeSharedDependencies, sharedDependencies, source } = context;
|
|
10
|
+
|
|
11
|
+
const entry: Config = { main: [`./${source}/index`] };
|
|
12
|
+
|
|
13
|
+
if (isExposeSharedDependencies) {
|
|
14
|
+
(entry.main as string[]).push(...Object.keys(sharedDependencies).map(getModuleEntryPath));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return { entry };
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Configuration } from 'webpack';
|
|
2
|
+
import { Context, Overrides } from './types';
|
|
3
|
+
|
|
4
|
+
type Config = Configuration['externals'];
|
|
5
|
+
type Result = Pick<Configuration, 'externals'> | undefined;
|
|
6
|
+
|
|
7
|
+
export function externalsConfig(context: Context, _: Overrides): Result {
|
|
8
|
+
const { embed, name, sharedDependencies } = context;
|
|
9
|
+
if (!embed) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const externals: Config = Object.fromEntries(
|
|
14
|
+
Object.entries(sharedDependencies).map(([dependency, variable]) => [
|
|
15
|
+
dependency,
|
|
16
|
+
`${variable}['${name}']`,
|
|
17
|
+
])
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
return { externals };
|
|
21
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './cache-config';
|
|
2
|
+
export * from './dev-server-config';
|
|
3
|
+
export * from './devtool-config';
|
|
4
|
+
export * from './entry.config';
|
|
5
|
+
export * from './externals-config';
|
|
6
|
+
export * from './module-config';
|
|
7
|
+
export * from './optimization-config';
|
|
8
|
+
export * from './output-config';
|
|
9
|
+
export * from './plugins-config';
|
|
10
|
+
export * from './resolve-config';
|
|
11
|
+
export * from './stats-config';
|
|
12
|
+
export * from './types';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Context } from '../types';
|
|
2
|
+
import { LoaderOptions } from './types';
|
|
3
|
+
|
|
4
|
+
export function cssLoader({ isProduction }: Context, { esModule }: LoaderOptions = {}) {
|
|
5
|
+
const loader = 'css-loader';
|
|
6
|
+
return esModule
|
|
7
|
+
? {
|
|
8
|
+
loader,
|
|
9
|
+
options: {
|
|
10
|
+
esModule,
|
|
11
|
+
modules: {
|
|
12
|
+
...(isProduction ? { localIdentName: '[local]__[hash:base64:5]' } : {}),
|
|
13
|
+
exportLocalsConvention: 'camelCaseOnly',
|
|
14
|
+
namedExport: true,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
: loader;
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
2
|
+
import { Context } from '../types';
|
|
3
|
+
import { LoaderOptions } from './types';
|
|
4
|
+
|
|
5
|
+
export function styleLoader(
|
|
6
|
+
{ isProduction, isWebComponent }: Context,
|
|
7
|
+
{ esModule }: LoaderOptions = {}
|
|
8
|
+
) {
|
|
9
|
+
const loader = isProduction || isWebComponent ? MiniCssExtractPlugin.loader : 'style-loader';
|
|
10
|
+
return esModule ? { loader, options: { esModule } } : loader;
|
|
11
|
+
}
|