@servicetitan/startup 31.3.2 → 31.5.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 +0 -7
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +28 -17
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/bundle-package.d.ts +1 -1
- package/dist/cli/commands/bundle-package.d.ts.map +1 -1
- package/dist/cli/commands/bundle-package.js +13 -21
- package/dist/cli/commands/bundle-package.js.map +1 -1
- package/dist/cli/commands/clean.js +1 -1
- package/dist/cli/commands/clean.js.map +1 -1
- package/dist/cli/commands/eslint.d.ts +0 -1
- package/dist/cli/commands/eslint.d.ts.map +1 -1
- package/dist/cli/commands/eslint.js +0 -3
- package/dist/cli/commands/eslint.js.map +1 -1
- package/dist/cli/commands/get-command.d.ts.map +1 -1
- package/dist/cli/commands/get-command.js +3 -1
- package/dist/cli/commands/get-command.js.map +1 -1
- package/dist/cli/commands/get-user-commands.js +3 -2
- package/dist/cli/commands/get-user-commands.js.map +1 -1
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/install.js.map +1 -1
- package/dist/cli/commands/lint.js.map +1 -1
- package/dist/cli/commands/mfe-package-clean.d.ts +3 -4
- package/dist/cli/commands/mfe-package-clean.d.ts.map +1 -1
- package/dist/cli/commands/mfe-package-clean.js +0 -3
- package/dist/cli/commands/mfe-package-clean.js.map +1 -1
- package/dist/cli/commands/mfe-package-publish.d.ts +9 -4
- package/dist/cli/commands/mfe-package-publish.d.ts.map +1 -1
- package/dist/cli/commands/mfe-package-publish.js +70 -47
- package/dist/cli/commands/mfe-package-publish.js.map +1 -1
- package/dist/cli/commands/mfe-publish.d.ts +3 -3
- package/dist/cli/commands/mfe-publish.d.ts.map +1 -1
- package/dist/cli/commands/mfe-publish.js +7 -1
- package/dist/cli/commands/mfe-publish.js.map +1 -1
- package/dist/cli/commands/prepare-package.d.ts +0 -1
- package/dist/cli/commands/prepare-package.d.ts.map +1 -1
- package/dist/cli/commands/prepare-package.js +0 -3
- package/dist/cli/commands/prepare-package.js.map +1 -1
- package/dist/cli/commands/review/review.js.map +1 -1
- package/dist/cli/commands/review/rules/require-one-anvil-uikit-contrib-version.js.map +1 -1
- package/dist/cli/commands/review/rules/require-one-collection-version.js.map +1 -1
- package/dist/cli/commands/review/rules/require-one-uikit-version.js.map +1 -1
- package/dist/cli/commands/run-task.d.ts +0 -1
- package/dist/cli/commands/run-task.d.ts.map +1 -1
- package/dist/cli/commands/run-task.js +0 -3
- package/dist/cli/commands/run-task.js.map +1 -1
- package/dist/cli/commands/start.d.ts +0 -8
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +28 -16
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/styles-check.d.ts +0 -1
- package/dist/cli/commands/styles-check.d.ts.map +1 -1
- package/dist/cli/commands/styles-check.js +40 -99
- package/dist/cli/commands/styles-check.js.map +1 -1
- package/dist/cli/commands/tests.js.map +1 -1
- package/dist/cli/commands/types.d.ts +1 -1
- package/dist/cli/commands/types.d.ts.map +1 -1
- package/dist/cli/commands/upload-sourcemaps.d.ts +22 -0
- package/dist/cli/commands/upload-sourcemaps.d.ts.map +1 -0
- package/dist/cli/commands/upload-sourcemaps.js +179 -0
- package/dist/cli/commands/upload-sourcemaps.js.map +1 -0
- package/dist/cli/tasks/cli-task.js.map +1 -1
- package/dist/cli/tasks/swc-compile-package.js.map +1 -1
- package/dist/cli/tasks/task.js.map +1 -1
- package/dist/cli/tasks/tsc-compile-package.js.map +1 -1
- package/dist/cli/tasks/tsc-compile.js.map +1 -1
- package/dist/cli/utils/bundle.d.ts +4 -1
- package/dist/cli/utils/bundle.d.ts.map +1 -1
- package/dist/cli/utils/bundle.js +67 -74
- package/dist/cli/utils/bundle.js.map +1 -1
- package/dist/cli/utils/cli-os.js +2 -2
- package/dist/cli/utils/cli-os.js.map +1 -1
- package/dist/cli/utils/ts-config.js.map +1 -1
- package/dist/utils/find-packages.d.ts.map +1 -1
- package/dist/utils/find-packages.js +3 -4
- package/dist/utils/find-packages.js.map +1 -1
- package/dist/utils/find-up.d.ts +2 -0
- package/dist/utils/find-up.d.ts.map +1 -0
- package/dist/utils/find-up.js +28 -0
- package/dist/utils/find-up.js.map +1 -0
- package/dist/utils/get-configuration.d.ts +3 -1
- package/dist/utils/get-configuration.d.ts.map +1 -1
- package/dist/utils/get-configuration.js +1 -0
- package/dist/utils/get-configuration.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/log.js.map +1 -1
- 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 +52 -0
- package/dist/webpack/configs/cache-config.js.map +1 -0
- package/dist/webpack/configs/dev-server-config.js +1 -1
- package/dist/webpack/configs/dev-server-config.js.map +1 -1
- package/dist/webpack/configs/entry.config.d.ts.map +1 -1
- package/dist/webpack/configs/entry.config.js +15 -6
- package/dist/webpack/configs/entry.config.js.map +1 -1
- package/dist/webpack/configs/externals-config.d.ts.map +1 -1
- package/dist/webpack/configs/externals-config.js +6 -2
- package/dist/webpack/configs/externals-config.js.map +1 -1
- package/dist/webpack/configs/index.d.ts +1 -0
- package/dist/webpack/configs/index.d.ts.map +1 -1
- package/dist/webpack/configs/index.js +1 -0
- package/dist/webpack/configs/index.js.map +1 -1
- package/dist/webpack/configs/optimization-config.d.ts.map +1 -1
- package/dist/webpack/configs/optimization-config.js +7 -11
- package/dist/webpack/configs/optimization-config.js.map +1 -1
- package/dist/webpack/configs/output-config.d.ts.map +1 -1
- package/dist/webpack/configs/output-config.js +25 -4
- package/dist/webpack/configs/output-config.js.map +1 -1
- package/dist/webpack/configs/plugins/assets-manifest-plugin.d.ts +6 -0
- package/dist/webpack/configs/plugins/assets-manifest-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/assets-manifest-plugin.js +50 -8
- package/dist/webpack/configs/plugins/assets-manifest-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.js +3 -7
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.js +3 -2
- package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/define-exposed-instance-dependencies-plugin.js +2 -2
- package/dist/webpack/configs/plugins/define-exposed-instance-dependencies-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/html-plugin.d.ts +1 -1
- package/dist/webpack/configs/plugins/html-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/html-plugin.js +2 -3
- package/dist/webpack/configs/plugins/html-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/html-tags-plugin.d.ts +4 -0
- package/dist/webpack/configs/plugins/html-tags-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/html-tags-plugin.js +49 -0
- package/dist/webpack/configs/plugins/html-tags-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/index.d.ts +2 -0
- package/dist/webpack/configs/plugins/index.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/index.js +2 -0
- package/dist/webpack/configs/plugins/index.js.map +1 -1
- package/dist/webpack/configs/plugins/remove-empty-scripts-plugin.d.ts +4 -0
- package/dist/webpack/configs/plugins/remove-empty-scripts-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/remove-empty-scripts-plugin.js +25 -0
- package/dist/webpack/configs/plugins/remove-empty-scripts-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/virtual-modules-plugin.d.ts +1 -0
- package/dist/webpack/configs/plugins/virtual-modules-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/virtual-modules-plugin.js +23 -14
- package/dist/webpack/configs/plugins/virtual-modules-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins-config.d.ts.map +1 -1
- package/dist/webpack/configs/plugins-config.js +2 -0
- package/dist/webpack/configs/plugins-config.js.map +1 -1
- package/dist/webpack/configs/rules/css-rules.d.ts.map +1 -1
- package/dist/webpack/configs/rules/css-rules.js +13 -18
- package/dist/webpack/configs/rules/css-rules.js.map +1 -1
- package/dist/webpack/configs/utils/get-bundle-type.d.ts +3 -0
- package/dist/webpack/configs/utils/get-bundle-type.d.ts.map +1 -0
- package/dist/webpack/configs/utils/get-bundle-type.js +24 -0
- package/dist/webpack/configs/utils/get-bundle-type.js.map +1 -0
- package/dist/webpack/configs/utils/index.d.ts +1 -0
- package/dist/webpack/configs/utils/index.d.ts.map +1 -1
- package/dist/webpack/configs/utils/index.js +1 -0
- package/dist/webpack/configs/utils/index.js.map +1 -1
- package/dist/webpack/create-webpack-config.d.ts.map +1 -1
- package/dist/webpack/create-webpack-config.js +37 -48
- package/dist/webpack/create-webpack-config.js.map +1 -1
- package/dist/webpack/types.d.ts +4 -0
- package/dist/webpack/types.d.ts.map +1 -1
- package/dist/webpack/utils/index.d.ts +1 -0
- package/dist/webpack/utils/index.d.ts.map +1 -1
- package/dist/webpack/utils/index.js +1 -0
- package/dist/webpack/utils/index.js.map +1 -1
- package/dist/webpack/utils/stringify-config.d.ts +2 -0
- package/dist/webpack/utils/stringify-config.d.ts.map +1 -0
- package/dist/webpack/utils/stringify-config.js +35 -0
- package/dist/webpack/utils/stringify-config.js.map +1 -0
- package/package.json +17 -15
- package/src/cli/commands/__tests__/build.test.ts +19 -2
- package/src/cli/commands/__tests__/bundle-package.test.ts +29 -8
- package/src/cli/commands/__tests__/clean.test.ts +2 -0
- package/src/cli/commands/__tests__/get-user-commands.test.ts +1 -1
- package/src/cli/commands/__tests__/mfe-package-publish.test.ts +91 -15
- package/src/cli/commands/__tests__/mfe-publish.test.ts +2 -0
- package/src/cli/commands/__tests__/start.test.ts +15 -1
- package/src/cli/commands/__tests__/styles-check.test.ts +27 -80
- package/src/cli/commands/__tests__/upload-sourcemaps.test.ts +127 -0
- package/src/cli/commands/build.ts +33 -17
- package/src/cli/commands/bundle-package.ts +10 -19
- package/src/cli/commands/clean.ts +1 -1
- package/src/cli/commands/eslint.ts +0 -4
- package/src/cli/commands/get-command.ts +2 -0
- package/src/cli/commands/get-user-commands.ts +1 -1
- package/src/cli/commands/mfe-package-clean.ts +2 -6
- package/src/cli/commands/mfe-package-publish.ts +104 -70
- package/src/cli/commands/mfe-publish.ts +8 -5
- package/src/cli/commands/prepare-package.ts +0 -4
- package/src/cli/commands/run-task.ts +0 -4
- package/src/cli/commands/start.ts +22 -5
- package/src/cli/commands/styles-check.ts +28 -131
- package/src/cli/commands/types.ts +1 -1
- package/src/cli/commands/upload-sourcemaps.ts +108 -0
- package/src/cli/utils/__tests__/bundle.test.ts +119 -9
- package/src/cli/utils/__tests__/cli-os.test.ts +2 -2
- package/src/cli/utils/__tests__/compile.test.ts +2 -0
- package/src/cli/utils/__tests__/type-check.test.ts +2 -0
- package/src/cli/utils/bundle.ts +76 -54
- package/src/cli/utils/cli-os.ts +2 -2
- package/src/utils/__tests__/get-configuration.test.ts +1 -1
- package/src/utils/find-packages.ts +3 -5
- package/src/utils/find-up.ts +12 -0
- package/src/utils/get-configuration.ts +2 -0
- package/src/utils/index.ts +1 -0
- package/src/webpack/__mocks__/style-rules.ts +1 -1
- package/src/webpack/__tests__/create-webpack-config-shared-dependencies.test.ts +274 -45
- package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +25 -1
- package/src/webpack/__tests__/create-webpack-config.test.ts +9 -57
- package/src/webpack/configs/cache-config.ts +37 -0
- package/src/webpack/configs/dev-server-config.ts +1 -1
- package/src/webpack/configs/entry.config.ts +18 -8
- package/src/webpack/configs/externals-config.ts +7 -2
- package/src/webpack/configs/index.ts +1 -0
- package/src/webpack/configs/optimization-config.ts +7 -11
- package/src/webpack/configs/output-config.ts +23 -7
- package/src/webpack/configs/plugins/assets-manifest-plugin.ts +46 -10
- package/src/webpack/configs/plugins/bundle-analyser-plugin.ts +1 -6
- package/src/webpack/configs/plugins/define-exposed-dependencies-plugin.ts +3 -2
- package/src/webpack/configs/plugins/define-exposed-instance-dependencies-plugin.ts +2 -2
- package/src/webpack/configs/plugins/html-plugin.ts +2 -3
- package/src/webpack/configs/plugins/html-tags-plugin.ts +28 -0
- package/src/webpack/configs/plugins/index.ts +2 -0
- package/src/webpack/configs/plugins/remove-empty-scripts-plugin.ts +11 -0
- package/src/webpack/configs/plugins/virtual-modules-plugin.ts +27 -16
- package/src/webpack/configs/plugins-config.ts +4 -0
- package/src/webpack/configs/rules/css-rules.ts +19 -20
- package/src/webpack/configs/utils/get-bundle-type.ts +22 -0
- package/src/webpack/configs/utils/index.ts +1 -0
- package/src/webpack/create-webpack-config.ts +46 -52
- package/src/webpack/types.ts +4 -0
- package/src/webpack/utils/index.ts +1 -0
- package/src/webpack/utils/stringify-config.ts +19 -0
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import path from 'path';
|
|
2
2
|
import { RuleSetRule } from 'webpack';
|
|
3
|
+
import { log } from '../../../utils';
|
|
3
4
|
import { cssLoader, styleLoader } from '../loaders';
|
|
4
5
|
import { Context } from '../types';
|
|
5
6
|
|
|
6
|
-
const sharedCssDependencies = [/design-system\.css$/, /@servicetitan[\\/]anvil2[\\/].*\.css$/];
|
|
7
|
-
|
|
8
7
|
export function cssRules(context: Context): RuleSetRule[] {
|
|
9
|
-
const { isExposeSharedDependencies,
|
|
10
|
-
|
|
11
|
-
const excludeCallback = (path: string) => {
|
|
12
|
-
return (
|
|
13
|
-
path.endsWith('.module.css') ||
|
|
14
|
-
(isExposeSharedDependencies && sharedCssDependencies.some(regex => regex.test(path)))
|
|
15
|
-
);
|
|
16
|
-
};
|
|
17
|
-
|
|
8
|
+
const { emitExposedDependencies, isExposeSharedDependencies, sharedDependencies } = context;
|
|
18
9
|
const result: RuleSetRule[] = [
|
|
19
10
|
{
|
|
20
11
|
test: /\.module.css$/,
|
|
@@ -22,18 +13,26 @@ export function cssRules(context: Context): RuleSetRule[] {
|
|
|
22
13
|
},
|
|
23
14
|
{
|
|
24
15
|
test: /(\.css)$/,
|
|
25
|
-
exclude:
|
|
16
|
+
exclude: /\.module.css$/,
|
|
26
17
|
use: [styleLoader(context), cssLoader(context)],
|
|
27
18
|
},
|
|
28
19
|
];
|
|
29
20
|
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
21
|
+
if (
|
|
22
|
+
isExposeSharedDependencies &&
|
|
23
|
+
!!sharedDependencies['@servicetitan/design-system'] &&
|
|
24
|
+
!emitExposedDependencies
|
|
25
|
+
) {
|
|
26
|
+
result.push({
|
|
27
|
+
test: /[\\/]design-system.css$/,
|
|
28
|
+
use({ issuer }) {
|
|
29
|
+
const filename = path.basename(issuer, '.js');
|
|
30
|
+
log.error(
|
|
31
|
+
`Error: do not import design-system.css in "${filename}"; it is automatically included as a shared dependency`
|
|
32
|
+
);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
},
|
|
35
|
+
});
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
return result;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Context } from '../types';
|
|
2
|
+
|
|
3
|
+
export function getBundleType({
|
|
4
|
+
embed,
|
|
5
|
+
emitExposedDependencies,
|
|
6
|
+
headless,
|
|
7
|
+
isExposeSharedDependencies,
|
|
8
|
+
isWebComponent,
|
|
9
|
+
}: Context) {
|
|
10
|
+
if (isExposeSharedDependencies && emitExposedDependencies) {
|
|
11
|
+
return 'shared';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (isWebComponent) {
|
|
15
|
+
if (headless) {
|
|
16
|
+
return 'headless';
|
|
17
|
+
}
|
|
18
|
+
return embed ? 'light' : 'full';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import {
|
|
18
18
|
Context,
|
|
19
19
|
amdConfig,
|
|
20
|
+
cacheConfig,
|
|
20
21
|
devServerConfig,
|
|
21
22
|
devtoolConfig,
|
|
22
23
|
entryConfig,
|
|
@@ -30,11 +31,46 @@ import {
|
|
|
30
31
|
watchOptionsConfig,
|
|
31
32
|
} from './configs';
|
|
32
33
|
import { Options, Overrides } from './types';
|
|
33
|
-
import { getCallerFile } from './utils';
|
|
34
|
+
import { getCallerFile, stringifyConfig } from './utils';
|
|
34
35
|
|
|
35
36
|
export function createWebpackConfig(overrides: Overrides, options: Options = {}): Configuration {
|
|
36
|
-
const
|
|
37
|
+
const context = getContext(overrides, options);
|
|
38
|
+
if (context.isWebComponent && isCalledFromCustomWebpackConfigFile()) {
|
|
39
|
+
throw new Error(WEB_COMPONENT_CONFIG_ERROR);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (options.emitExposedDependencies && !context.isExposeSharedDependencies) {
|
|
43
|
+
throw new Error('package does not expose shared dependencies');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const configs = [
|
|
47
|
+
amdConfig,
|
|
48
|
+
cacheConfig,
|
|
49
|
+
devServerConfig,
|
|
50
|
+
devtoolConfig,
|
|
51
|
+
entryConfig,
|
|
52
|
+
externalsConfig,
|
|
53
|
+
moduleConfig,
|
|
54
|
+
optimizationConfig,
|
|
55
|
+
outputConfig,
|
|
56
|
+
pluginsConfig,
|
|
57
|
+
resolveConfig,
|
|
58
|
+
statsConfig,
|
|
59
|
+
watchOptionsConfig,
|
|
60
|
+
];
|
|
37
61
|
|
|
62
|
+
const result = merge(
|
|
63
|
+
configs.reduce((result, fn) => ({ ...result, ...fn(context, overrides) }), {}),
|
|
64
|
+
overrides.configuration ?? {}
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
/* istanbul ignore next: debug only */
|
|
68
|
+
log.debug('create-webpack-config', () => stringifyConfig(result));
|
|
69
|
+
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function getContext({ configuration = {} }: Overrides, options: Options): Context {
|
|
38
74
|
const { source, destination } = getFolders();
|
|
39
75
|
const { minify } = getWebpackConfiguration();
|
|
40
76
|
const packageData = getPackageData();
|
|
@@ -43,10 +79,15 @@ export function createWebpackConfig(overrides: Overrides, options: Options = {})
|
|
|
43
79
|
packageData.sharedDependencies
|
|
44
80
|
);
|
|
45
81
|
|
|
46
|
-
const
|
|
47
|
-
|
|
82
|
+
const args = argv as Arguments;
|
|
83
|
+
const emitExposedDependencies =
|
|
84
|
+
options.emitExposedDependencies ?? !!args['exposed-dependencies'];
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
codeCoverage: options.codeCoverage ?? !!args['code-coverage'],
|
|
48
88
|
destination,
|
|
49
|
-
|
|
89
|
+
emitExposedDependencies,
|
|
90
|
+
isCustomStyleRules: !emitExposedDependencies && isCustomStyleRules(),
|
|
50
91
|
isExposeSharedDependencies: isExposeSharedDependencies(),
|
|
51
92
|
isLegacyRoot: isLegacyRoot(),
|
|
52
93
|
isProduction: configuration.mode === 'production',
|
|
@@ -58,33 +99,6 @@ export function createWebpackConfig(overrides: Overrides, options: Options = {})
|
|
|
58
99
|
sharedDependencies,
|
|
59
100
|
source,
|
|
60
101
|
};
|
|
61
|
-
|
|
62
|
-
if (context.isWebComponent && isCalledFromCustomWebpackConfigFile()) {
|
|
63
|
-
throw new Error(WEB_COMPONENT_CONFIG_ERROR);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const result = merge(
|
|
67
|
-
[
|
|
68
|
-
amdConfig,
|
|
69
|
-
devServerConfig,
|
|
70
|
-
devtoolConfig,
|
|
71
|
-
entryConfig,
|
|
72
|
-
externalsConfig,
|
|
73
|
-
moduleConfig,
|
|
74
|
-
optimizationConfig,
|
|
75
|
-
outputConfig,
|
|
76
|
-
pluginsConfig,
|
|
77
|
-
resolveConfig,
|
|
78
|
-
statsConfig,
|
|
79
|
-
watchOptionsConfig,
|
|
80
|
-
].reduce((result, fn) => ({ ...result, ...fn(context, overrides) }), {}),
|
|
81
|
-
configuration
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
/* istanbul ignore next: debug only */
|
|
85
|
-
log.debug('create-webpack-config', () => stringify(result));
|
|
86
|
-
|
|
87
|
-
return result;
|
|
88
102
|
}
|
|
89
103
|
|
|
90
104
|
function isCalledFromCustomWebpackConfigFile() {
|
|
@@ -94,26 +108,6 @@ function isCalledFromCustomWebpackConfigFile() {
|
|
|
94
108
|
);
|
|
95
109
|
}
|
|
96
110
|
|
|
97
|
-
/* istanbul ignore next: debug only */
|
|
98
|
-
function stringify(configuration: any) {
|
|
99
|
-
function replacer(key: string, value: any) {
|
|
100
|
-
if (typeof value === 'function') {
|
|
101
|
-
return `Function(${value.name ?? ''})`;
|
|
102
|
-
}
|
|
103
|
-
if (value instanceof RegExp) {
|
|
104
|
-
return String(value);
|
|
105
|
-
}
|
|
106
|
-
if (key === 'plugins' && Array.isArray(value)) {
|
|
107
|
-
return value.map(plugin => {
|
|
108
|
-
const name = plugin.constructor?.name ?? plugin.name;
|
|
109
|
-
return name ? { [name]: plugin } : plugin;
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
return value;
|
|
113
|
-
}
|
|
114
|
-
return JSON.stringify(configuration, replacer, 2);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
111
|
const WEB_COMPONENT_CONFIG_ERROR = `
|
|
118
112
|
You cannot call createWebpackConfig in a custom webpack config file in a web component (MFE) project.
|
|
119
113
|
Export webpack configuration itself as a default export from the config file instead.
|
package/src/webpack/types.ts
CHANGED
|
@@ -2,10 +2,14 @@ import { Options as HtmlWebpackPluginOptions } from 'html-webpack-plugin';
|
|
|
2
2
|
import { PluginOptions as MiniCssExtractPlugInOptions } from 'mini-css-extract-plugin';
|
|
3
3
|
import { Configuration } from 'webpack';
|
|
4
4
|
|
|
5
|
+
export interface ExposedDependenciesConfig {
|
|
6
|
+
output?: Configuration['output'];
|
|
7
|
+
}
|
|
5
8
|
export interface Options {
|
|
6
9
|
buildStat?: boolean;
|
|
7
10
|
codeCoverage?: boolean;
|
|
8
11
|
embed?: boolean;
|
|
12
|
+
emitExposedDependencies?: boolean | ExposedDependenciesConfig;
|
|
9
13
|
headless?: boolean;
|
|
10
14
|
name?: string;
|
|
11
15
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* istanbul ignore next: debug only */
|
|
2
|
+
export function stringifyConfig(configuration: any) {
|
|
3
|
+
function replacer(key: string, value: any) {
|
|
4
|
+
if (typeof value === 'function') {
|
|
5
|
+
return `Function(${value.name ?? ''})`;
|
|
6
|
+
}
|
|
7
|
+
if (value instanceof RegExp) {
|
|
8
|
+
return String(value);
|
|
9
|
+
}
|
|
10
|
+
if (key === 'plugins' && Array.isArray(value)) {
|
|
11
|
+
return value.map(plugin => {
|
|
12
|
+
const name = plugin.constructor?.name ?? plugin.name;
|
|
13
|
+
return name ? { [name]: plugin } : plugin;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
return JSON.stringify(configuration, replacer, 2);
|
|
19
|
+
}
|