@teambit/webpack 0.0.555 → 0.0.556
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/package.json +16 -10
- package/config/html.ts +0 -22
- package/config/webpack-fallbacks-aliases.ts +0 -4
- package/config/webpack-fallbacks-provide-plugin-config.ts +0 -4
- package/config/webpack-fallbacks.ts +0 -60
- package/config/webpack-preview.config.ts +0 -59
- package/config/webpack.config.ts +0 -32
- package/config/webpack.dev.config.ts +0 -156
- package/events/index.ts +0 -2
- package/events/webpack-compilation-done-event.ts +0 -20
- package/events/webpack-compilation-started-event.ts +0 -14
- package/index.ts +0 -20
- package/package-tar/teambit-webpack-0.0.555.tgz +0 -0
- package/plugins/webpack-bit-reporter-plugin.ts +0 -33
- package/tsconfig.json +0 -34
- package/types/asset.d.ts +0 -29
- package/types/style.d.ts +0 -42
- package/webpack.aspect.ts +0 -5
- package/webpack.bundler.ts +0 -72
- package/webpack.composition.tsx +0 -7
- package/webpack.dev-server.ts +0 -63
- package/webpack.main.runtime.ts +0 -175
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/webpack",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.556",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/webpack/webpack",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.webpack",
|
|
8
8
|
"name": "webpack",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.556"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"webpack": "5.51.1",
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"assert": "2.0.0",
|
|
39
39
|
"@babel/runtime": "7.12.18",
|
|
40
40
|
"core-js": "^3.0.0",
|
|
41
|
-
"@teambit/webpack.modules.config-mutator": "0.0.
|
|
42
|
-
"@teambit/bit-error": "0.0.
|
|
43
|
-
"@teambit/bundler": "0.0.
|
|
44
|
-
"@teambit/logger": "0.0.
|
|
45
|
-
"@teambit/cli": "0.0.
|
|
46
|
-
"@teambit/pubsub": "0.0.
|
|
47
|
-
"@teambit/workspace": "0.0.
|
|
41
|
+
"@teambit/webpack.modules.config-mutator": "0.0.113",
|
|
42
|
+
"@teambit/bit-error": "0.0.373",
|
|
43
|
+
"@teambit/bundler": "0.0.556",
|
|
44
|
+
"@teambit/logger": "0.0.472",
|
|
45
|
+
"@teambit/cli": "0.0.387",
|
|
46
|
+
"@teambit/pubsub": "0.0.556",
|
|
47
|
+
"@teambit/workspace": "0.0.556"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/webpack": "5.28.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@types/node": "12.20.4"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@teambit/legacy": "1.0.
|
|
59
|
+
"@teambit/legacy": "1.0.173",
|
|
60
60
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
61
61
|
"react": "^16.8.0 || ^17.0.0"
|
|
62
62
|
},
|
|
@@ -107,6 +107,12 @@
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
|
+
"files": [
|
|
111
|
+
"dist",
|
|
112
|
+
"!dist/tsconfig.tsbuildinfo",
|
|
113
|
+
"README.md",
|
|
114
|
+
"README.mdx"
|
|
115
|
+
],
|
|
110
116
|
"private": false,
|
|
111
117
|
"engines": {
|
|
112
118
|
"node": ">=12.22.0"
|
package/config/html.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/** html template for Previews (docs, compositions, etc) */
|
|
2
|
-
export function html(title: string) {
|
|
3
|
-
return () => `
|
|
4
|
-
<!DOCTYPE html>
|
|
5
|
-
<html lang="en">
|
|
6
|
-
<head>
|
|
7
|
-
<meta charset="utf-8">
|
|
8
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
9
|
-
<title>${title}</title>
|
|
10
|
-
<script>
|
|
11
|
-
// Allow to use react dev-tools inside the examples
|
|
12
|
-
try { window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__; } catch {}
|
|
13
|
-
</script>
|
|
14
|
-
<!-- minimal css resets -->
|
|
15
|
-
<style> html { height: 100%; } body { margin: 0; height: 100%; } #root { height: 100%; } </style>
|
|
16
|
-
</head>
|
|
17
|
-
<body>
|
|
18
|
-
<div id="root"></div>
|
|
19
|
-
</body>
|
|
20
|
-
</html>
|
|
21
|
-
`;
|
|
22
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// based on https://github1s.com/vercel/next.js/blob/canary/packages/next/build/webpack-config.ts
|
|
2
|
-
// Full list of old polyfills is accessible here:
|
|
3
|
-
// https://github.com/webpack/webpack/blob/2a0536cf510768111a3a6dceeb14cb79b9f59273/lib/ModuleNotFoundError.js#L13-L42
|
|
4
|
-
|
|
5
|
-
const assertFallbackPath = require.resolve('assert/');
|
|
6
|
-
const bufferFallbackPath = require.resolve('buffer/');
|
|
7
|
-
const constantsFallbackPath = require.resolve('constants-browserify');
|
|
8
|
-
const cryptoFallbackPath = require.resolve('crypto-browserify');
|
|
9
|
-
const domainFallbackPath = require.resolve('domain-browser');
|
|
10
|
-
const httpFallbackPath = require.resolve('stream-http');
|
|
11
|
-
const httpsFallbackPath = require.resolve('https-browserify');
|
|
12
|
-
const osFallbackPath = require.resolve('os-browserify/browser');
|
|
13
|
-
const pathFallbackPath = require.resolve('path-browserify');
|
|
14
|
-
const punycodeFallbackPath = require.resolve('punycode/');
|
|
15
|
-
const processFallbackPath = require.resolve('process/browser');
|
|
16
|
-
// Handled in separate alias
|
|
17
|
-
const querystringFallbackPath = require.resolve('querystring-es3');
|
|
18
|
-
const streamFallbackPath = require.resolve('stream-browserify');
|
|
19
|
-
const string_decoderFallbackPath = require.resolve('string_decoder/');
|
|
20
|
-
const sysFallbackPath = require.resolve('util/');
|
|
21
|
-
const timersFallbackPath = require.resolve('timers-browserify');
|
|
22
|
-
const ttyFallbackPath = require.resolve('tty-browserify');
|
|
23
|
-
// Handled in separate alias
|
|
24
|
-
const urlFallbackPath = require.resolve('url/');
|
|
25
|
-
const utilFallbackPath = require.resolve('util/');
|
|
26
|
-
const vmFallbackPath = require.resolve('vm-browserify');
|
|
27
|
-
const zlibFallbackPath = require.resolve('browserify-zlib');
|
|
28
|
-
|
|
29
|
-
export const fallbacks = {
|
|
30
|
-
assert: assertFallbackPath,
|
|
31
|
-
buffer: bufferFallbackPath,
|
|
32
|
-
constants: constantsFallbackPath,
|
|
33
|
-
crypto: cryptoFallbackPath,
|
|
34
|
-
domain: domainFallbackPath,
|
|
35
|
-
http: httpFallbackPath,
|
|
36
|
-
https: httpsFallbackPath,
|
|
37
|
-
os: osFallbackPath,
|
|
38
|
-
path: pathFallbackPath,
|
|
39
|
-
punycode: punycodeFallbackPath,
|
|
40
|
-
process: processFallbackPath,
|
|
41
|
-
querystring: querystringFallbackPath,
|
|
42
|
-
stream: streamFallbackPath,
|
|
43
|
-
string_decoder: string_decoderFallbackPath,
|
|
44
|
-
sys: sysFallbackPath,
|
|
45
|
-
timers: timersFallbackPath,
|
|
46
|
-
tty: ttyFallbackPath,
|
|
47
|
-
url: urlFallbackPath,
|
|
48
|
-
util: utilFallbackPath,
|
|
49
|
-
vm: vmFallbackPath,
|
|
50
|
-
zlib: zlibFallbackPath,
|
|
51
|
-
fs: false,
|
|
52
|
-
net: false,
|
|
53
|
-
tls: false,
|
|
54
|
-
child_process: false,
|
|
55
|
-
// file: false,
|
|
56
|
-
// module: false,
|
|
57
|
-
// pnpapi: false,
|
|
58
|
-
// readline: false,
|
|
59
|
-
// worker_threads: false,
|
|
60
|
-
} as const;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import webpack, { Configuration } from 'webpack';
|
|
2
|
-
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
3
|
-
import { fallbacks } from './webpack-fallbacks';
|
|
4
|
-
import { fallbacksProvidePluginConfig } from './webpack-fallbacks-provide-plugin-config';
|
|
5
|
-
import { fallbacksAliases } from './webpack-fallbacks-aliases';
|
|
6
|
-
import { html } from './html';
|
|
7
|
-
|
|
8
|
-
export function previewConfigFactory(entries: string[], rootPath: string): Configuration {
|
|
9
|
-
return {
|
|
10
|
-
mode: 'production',
|
|
11
|
-
// Stop compilation early in production
|
|
12
|
-
bail: true,
|
|
13
|
-
// These are the "entry points" to our application.
|
|
14
|
-
// This means they will be the "root" imports that are included in JS bundle.
|
|
15
|
-
entry: entries.filter(Boolean),
|
|
16
|
-
|
|
17
|
-
output: {
|
|
18
|
-
// The build folder.
|
|
19
|
-
path: `${rootPath}/public`,
|
|
20
|
-
|
|
21
|
-
filename: 'static/js/[name].[contenthash:8].js',
|
|
22
|
-
// There are also additional JS chunk files if you use code splitting.
|
|
23
|
-
chunkFilename: 'static/js/[name].[contenthash:8].chunk.js',
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
resolve: {
|
|
27
|
-
alias: fallbacksAliases,
|
|
28
|
-
|
|
29
|
-
fallback: fallbacks,
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
plugins: [
|
|
33
|
-
new HtmlWebpackPlugin(
|
|
34
|
-
Object.assign(
|
|
35
|
-
{},
|
|
36
|
-
{
|
|
37
|
-
inject: true,
|
|
38
|
-
templateContent: html('Preview'),
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
minify: {
|
|
42
|
-
removeComments: true,
|
|
43
|
-
collapseWhitespace: true,
|
|
44
|
-
removeRedundantAttributes: true,
|
|
45
|
-
useShortDoctype: true,
|
|
46
|
-
removeEmptyAttributes: true,
|
|
47
|
-
removeStyleLinkTypeAttributes: true,
|
|
48
|
-
keepClosingSlash: true,
|
|
49
|
-
minifyJS: true,
|
|
50
|
-
minifyCSS: true,
|
|
51
|
-
minifyURLs: true,
|
|
52
|
-
},
|
|
53
|
-
}
|
|
54
|
-
)
|
|
55
|
-
),
|
|
56
|
-
new webpack.ProvidePlugin(fallbacksProvidePluginConfig),
|
|
57
|
-
],
|
|
58
|
-
};
|
|
59
|
-
}
|
package/config/webpack.config.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import webpack, { Configuration } from 'webpack';
|
|
2
|
-
import { fallbacks } from './webpack-fallbacks';
|
|
3
|
-
import { fallbacksProvidePluginConfig } from './webpack-fallbacks-provide-plugin-config';
|
|
4
|
-
import { fallbacksAliases } from './webpack-fallbacks-aliases';
|
|
5
|
-
|
|
6
|
-
export function configFactory(entries: string[], rootPath: string): Configuration {
|
|
7
|
-
return {
|
|
8
|
-
mode: 'production',
|
|
9
|
-
// Stop compilation early in production
|
|
10
|
-
bail: true,
|
|
11
|
-
// These are the "entry points" to our application.
|
|
12
|
-
// This means they will be the "root" imports that are included in JS bundle.
|
|
13
|
-
entry: entries.filter(Boolean),
|
|
14
|
-
|
|
15
|
-
output: {
|
|
16
|
-
// The build folder.
|
|
17
|
-
path: `${rootPath}/public`,
|
|
18
|
-
|
|
19
|
-
filename: 'static/js/[name].[contenthash:8].js',
|
|
20
|
-
// There are also additional JS chunk files if you use code splitting.
|
|
21
|
-
chunkFilename: 'static/js/[name].[contenthash:8].chunk.js',
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
resolve: {
|
|
25
|
-
alias: fallbacksAliases,
|
|
26
|
-
|
|
27
|
-
fallback: fallbacks,
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
plugins: [new webpack.ProvidePlugin(fallbacksProvidePluginConfig)],
|
|
31
|
-
};
|
|
32
|
-
}
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import webpack from 'webpack';
|
|
3
|
-
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
4
|
-
import errorOverlayMiddleware from 'react-dev-utils/errorOverlayMiddleware';
|
|
5
|
-
import evalSourceMapMiddleware from 'react-dev-utils/evalSourceMapMiddleware';
|
|
6
|
-
import noopServiceWorkerMiddleware from 'react-dev-utils/noopServiceWorkerMiddleware';
|
|
7
|
-
import redirectServedPath from 'react-dev-utils/redirectServedPathMiddleware';
|
|
8
|
-
import getPublicUrlOrPath from 'react-dev-utils/getPublicUrlOrPath';
|
|
9
|
-
import { PubsubMain } from '@teambit/pubsub';
|
|
10
|
-
import { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';
|
|
11
|
-
import { WebpackConfigWithDevServer } from '../webpack.dev-server';
|
|
12
|
-
import { fallbacks } from './webpack-fallbacks';
|
|
13
|
-
|
|
14
|
-
import { html } from './html';
|
|
15
|
-
|
|
16
|
-
import { WebpackBitReporterPlugin } from '../plugins/webpack-bit-reporter-plugin';
|
|
17
|
-
import { fallbacksProvidePluginConfig } from './webpack-fallbacks-provide-plugin-config';
|
|
18
|
-
import { fallbacksAliases } from './webpack-fallbacks-aliases';
|
|
19
|
-
|
|
20
|
-
const publicUrlOrPath = getPublicUrlOrPath(process.env.NODE_ENV === 'development', '/', '/public');
|
|
21
|
-
|
|
22
|
-
export function configFactory(
|
|
23
|
-
devServerID: string,
|
|
24
|
-
workspaceDir: string,
|
|
25
|
-
entryFiles: string[],
|
|
26
|
-
publicRoot: string,
|
|
27
|
-
publicPath: string,
|
|
28
|
-
pubsub: PubsubMain,
|
|
29
|
-
title?: string
|
|
30
|
-
): WebpackConfigWithDevServer {
|
|
31
|
-
const resolveWorkspacePath = (relativePath) => path.resolve(workspaceDir, relativePath);
|
|
32
|
-
|
|
33
|
-
// Required for babel-preset-react-app
|
|
34
|
-
process.env.NODE_ENV = 'development';
|
|
35
|
-
|
|
36
|
-
const publicDirectory = `${publicRoot}/${publicPath}`;
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
// Environment mode
|
|
40
|
-
mode: 'development',
|
|
41
|
-
|
|
42
|
-
devtool: 'inline-source-map',
|
|
43
|
-
|
|
44
|
-
// Entry point of app
|
|
45
|
-
entry: entryFiles.map((filePath) => resolveWorkspacePath(filePath)),
|
|
46
|
-
|
|
47
|
-
output: {
|
|
48
|
-
// Development filename output
|
|
49
|
-
filename: 'static/js/[name].bundle.js',
|
|
50
|
-
|
|
51
|
-
pathinfo: true,
|
|
52
|
-
|
|
53
|
-
path: resolveWorkspacePath(publicDirectory),
|
|
54
|
-
|
|
55
|
-
// publicPath: resolveWorkspacePath(publicDirectory),
|
|
56
|
-
|
|
57
|
-
chunkFilename: 'static/js/[name].chunk.js',
|
|
58
|
-
|
|
59
|
-
// point sourcemap entries to original disk locations (format as URL on windows)
|
|
60
|
-
devtoolModuleFilenameTemplate: (info) => pathNormalizeToLinux(path.resolve(info.absoluteResourcePath)),
|
|
61
|
-
|
|
62
|
-
// this defaults to 'window', but by setting it to 'this' then
|
|
63
|
-
// module chunks which are built will work in web workers as well.
|
|
64
|
-
// Commented out to use the default (self) as according to tobias with webpack5 self is working with workers as well
|
|
65
|
-
// globalObject: 'this',
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
infrastructureLogging: {
|
|
69
|
-
level: 'error',
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
stats: 'errors-only',
|
|
73
|
-
|
|
74
|
-
devServer: {
|
|
75
|
-
allowedHosts: 'all',
|
|
76
|
-
|
|
77
|
-
static: [
|
|
78
|
-
{
|
|
79
|
-
directory: resolveWorkspacePath(publicDirectory),
|
|
80
|
-
staticOptions: {},
|
|
81
|
-
// Don't be confused with `dev.publicPath`, it is `publicPath` for static directory
|
|
82
|
-
// Can be:
|
|
83
|
-
// publicPath: ['/static-public-path-one/', '/static-public-path-two/'],
|
|
84
|
-
publicPath: publicDirectory,
|
|
85
|
-
// Can be:
|
|
86
|
-
// serveIndex: {} (options for the `serveIndex` option you can find https://github.com/expressjs/serve-index)
|
|
87
|
-
serveIndex: true,
|
|
88
|
-
// Can be:
|
|
89
|
-
// watch: {} (options for the `watch` option you can find https://github.com/paulmillr/chokidar)
|
|
90
|
-
watch: true,
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
|
|
94
|
-
// Enable compression
|
|
95
|
-
compress: true,
|
|
96
|
-
|
|
97
|
-
// Enable hot reloading
|
|
98
|
-
hot: true,
|
|
99
|
-
|
|
100
|
-
historyApiFallback: {
|
|
101
|
-
disableDotRule: true,
|
|
102
|
-
index: resolveWorkspacePath(publicDirectory),
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
client: {
|
|
106
|
-
overlay: false,
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
onBeforeSetupMiddleware({ app, server }) {
|
|
110
|
-
// Keep `evalSourceMapMiddleware` and `errorOverlayMiddleware`
|
|
111
|
-
// middlewares before `redirectServedPath` otherwise will not have any effect
|
|
112
|
-
// This lets us fetch source contents from webpack for the error overlay
|
|
113
|
-
app.use(evalSourceMapMiddleware(server));
|
|
114
|
-
// This lets us open files from the runtime error overlay.
|
|
115
|
-
app.use(errorOverlayMiddleware());
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
onAfterSetupMiddleware({ app }) {
|
|
119
|
-
// Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match
|
|
120
|
-
app.use(redirectServedPath(publicUrlOrPath));
|
|
121
|
-
|
|
122
|
-
// This service worker file is effectively a 'no-op' that will reset any
|
|
123
|
-
// previous service worker registered for the same host:port combination.
|
|
124
|
-
// We do this in development to avoid hitting the production cache if
|
|
125
|
-
// it used the same host and port.
|
|
126
|
-
// https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
|
|
127
|
-
app.use(noopServiceWorkerMiddleware(publicUrlOrPath));
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
devMiddleware: {
|
|
131
|
-
// forward static files
|
|
132
|
-
publicPath: path.join('/', publicRoot),
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
resolve: {
|
|
137
|
-
extensions: ['.ts', '.tsx', '.js', '.mdx', '.md'],
|
|
138
|
-
alias: fallbacksAliases,
|
|
139
|
-
|
|
140
|
-
fallback: fallbacks as any,
|
|
141
|
-
},
|
|
142
|
-
|
|
143
|
-
plugins: [
|
|
144
|
-
new HtmlWebpackPlugin({
|
|
145
|
-
templateContent: html(title || 'Component preview'),
|
|
146
|
-
filename: 'index.html',
|
|
147
|
-
}),
|
|
148
|
-
|
|
149
|
-
new webpack.ProvidePlugin(fallbacksProvidePluginConfig),
|
|
150
|
-
|
|
151
|
-
new WebpackBitReporterPlugin({
|
|
152
|
-
options: { pubsub, devServerID },
|
|
153
|
-
}),
|
|
154
|
-
],
|
|
155
|
-
};
|
|
156
|
-
}
|
package/events/index.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-classes-per-file */
|
|
2
|
-
import type { Stats } from 'webpack';
|
|
3
|
-
import { BitBaseEvent } from '@teambit/pubsub';
|
|
4
|
-
|
|
5
|
-
class WebpackCompilationDoneEventData {
|
|
6
|
-
constructor(readonly stats: Stats, readonly devServerID: string) {}
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export class WebpackCompilationDoneEvent extends BitBaseEvent<WebpackCompilationDoneEventData> {
|
|
10
|
-
static readonly TYPE = 'webpack-compilation-done';
|
|
11
|
-
|
|
12
|
-
constructor(readonly timestamp: number, readonly stats: Stats, readonly devServerID: string) {
|
|
13
|
-
super(
|
|
14
|
-
WebpackCompilationDoneEvent.TYPE,
|
|
15
|
-
'0.0.1',
|
|
16
|
-
timestamp,
|
|
17
|
-
new WebpackCompilationDoneEventData(stats, devServerID)
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-classes-per-file */
|
|
2
|
-
import { BitBaseEvent } from '@teambit/pubsub';
|
|
3
|
-
|
|
4
|
-
type Params = {
|
|
5
|
-
devServerID: string;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export class WebpackCompilationStartedEvent extends BitBaseEvent<Params> {
|
|
9
|
-
static readonly TYPE = 'webpack-compilation-started';
|
|
10
|
-
|
|
11
|
-
constructor(readonly timestamp, readonly params: Params) {
|
|
12
|
-
super(WebpackCompilationStartedEvent.TYPE, '0.0.1', timestamp, params);
|
|
13
|
-
}
|
|
14
|
-
}
|
package/index.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
WebpackMain,
|
|
3
|
-
WebpackConfigTransformer,
|
|
4
|
-
WebpackConfigTransformContext,
|
|
5
|
-
WebpackConfigDevServerTransformContext,
|
|
6
|
-
GlobalWebpackConfigTransformContext,
|
|
7
|
-
WebpackConfigDevServerTransformer,
|
|
8
|
-
} from './webpack.main.runtime';
|
|
9
|
-
export { runTransformersWithContext } from './webpack.main.runtime';
|
|
10
|
-
export { WebpackAspect } from './webpack.aspect';
|
|
11
|
-
export { WebpackDevServer } from './webpack.dev-server';
|
|
12
|
-
export { WebpackBundler } from './webpack.bundler';
|
|
13
|
-
export type { WebpackConfigWithDevServer } from './webpack.dev-server';
|
|
14
|
-
export * from './events';
|
|
15
|
-
export { Configuration } from 'webpack';
|
|
16
|
-
export { WebpackConfigMutator } from '@teambit/webpack.modules.config-mutator';
|
|
17
|
-
export { WebpackBitReporterPlugin } from './plugins/webpack-bit-reporter-plugin';
|
|
18
|
-
export { fallbacks } from './config/webpack-fallbacks';
|
|
19
|
-
export { fallbacksAliases } from './config/webpack-fallbacks-aliases';
|
|
20
|
-
export { fallbacksProvidePluginConfig } from './config/webpack-fallbacks-provide-plugin-config';
|
|
Binary file
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Compiler, Stats } from 'webpack';
|
|
2
|
-
import { WebpackCompilationDoneEvent, WebpackCompilationStartedEvent } from '../events';
|
|
3
|
-
import { WebpackAspect } from '../webpack.aspect';
|
|
4
|
-
|
|
5
|
-
const PLUGIN_NAME = 'webpack-compiler-started-plugin';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Monitors Webpack's compilation, and updates progress to Bit
|
|
9
|
-
*/
|
|
10
|
-
export class WebpackBitReporterPlugin {
|
|
11
|
-
// TODO: add plugin type from webpack and implement it
|
|
12
|
-
pubsub: any;
|
|
13
|
-
devServerID: string;
|
|
14
|
-
|
|
15
|
-
constructor({ options }) {
|
|
16
|
-
this.pubsub = options.pubsub;
|
|
17
|
-
this.devServerID = options.devServerID;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
apply(compiler: Compiler) {
|
|
21
|
-
// "Called before a new compilation is created."
|
|
22
|
-
compiler.hooks.compile.tap(PLUGIN_NAME, () => {
|
|
23
|
-
const event = new WebpackCompilationStartedEvent(Date.now(), { devServerID: this.devServerID });
|
|
24
|
-
this.pubsub.pub(WebpackAspect.id, event);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
// "Executed when the compilation has completed."
|
|
28
|
-
compiler.hooks.done.tap(PLUGIN_NAME, (stats: Stats) => {
|
|
29
|
-
const event = new WebpackCompilationDoneEvent(Date.now(), stats, this.devServerID);
|
|
30
|
-
this.pubsub.pub(WebpackAspect.id, event);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"lib": [
|
|
4
|
-
"es2019",
|
|
5
|
-
"DOM",
|
|
6
|
-
"ES6",
|
|
7
|
-
"DOM.Iterable",
|
|
8
|
-
"ScriptHost"
|
|
9
|
-
],
|
|
10
|
-
"target": "es2015",
|
|
11
|
-
"module": "commonjs",
|
|
12
|
-
"jsx": "react",
|
|
13
|
-
"declaration": true,
|
|
14
|
-
"sourceMap": true,
|
|
15
|
-
"skipLibCheck": true,
|
|
16
|
-
"moduleResolution": "node",
|
|
17
|
-
"esModuleInterop": true,
|
|
18
|
-
"outDir": "dist",
|
|
19
|
-
"composite": true,
|
|
20
|
-
"emitDeclarationOnly": true,
|
|
21
|
-
"experimentalDecorators": true,
|
|
22
|
-
"emitDecoratorMetadata": true,
|
|
23
|
-
"allowSyntheticDefaultImports": true,
|
|
24
|
-
"strictPropertyInitialization": false,
|
|
25
|
-
"strict": true,
|
|
26
|
-
"noImplicitAny": false,
|
|
27
|
-
"rootDir": ".",
|
|
28
|
-
"preserveConstEnums": true,
|
|
29
|
-
"resolveJsonModule": true
|
|
30
|
-
},
|
|
31
|
-
"exclude": [
|
|
32
|
-
"dist"
|
|
33
|
-
]
|
|
34
|
-
}
|
package/types/asset.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
declare module '*.png' {
|
|
2
|
-
const value: any;
|
|
3
|
-
export = value;
|
|
4
|
-
}
|
|
5
|
-
declare module '*.svg' {
|
|
6
|
-
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
-
|
|
8
|
-
export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
|
|
9
|
-
const src: string;
|
|
10
|
-
export default src;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// @TODO Gilad
|
|
14
|
-
declare module '*.jpg' {
|
|
15
|
-
const value: any;
|
|
16
|
-
export = value;
|
|
17
|
-
}
|
|
18
|
-
declare module '*.jpeg' {
|
|
19
|
-
const value: any;
|
|
20
|
-
export = value;
|
|
21
|
-
}
|
|
22
|
-
declare module '*.gif' {
|
|
23
|
-
const value: any;
|
|
24
|
-
export = value;
|
|
25
|
-
}
|
|
26
|
-
declare module '*.bmp' {
|
|
27
|
-
const value: any;
|
|
28
|
-
export = value;
|
|
29
|
-
}
|
package/types/style.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
declare module '*.module.css' {
|
|
2
|
-
const classes: { readonly [key: string]: string };
|
|
3
|
-
export default classes;
|
|
4
|
-
}
|
|
5
|
-
declare module '*.module.scss' {
|
|
6
|
-
const classes: { readonly [key: string]: string };
|
|
7
|
-
export default classes;
|
|
8
|
-
}
|
|
9
|
-
declare module '*.module.sass' {
|
|
10
|
-
const classes: { readonly [key: string]: string };
|
|
11
|
-
export default classes;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
declare module '*.module.less' {
|
|
15
|
-
const classes: { readonly [key: string]: string };
|
|
16
|
-
export default classes;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
declare module '*.less' {
|
|
20
|
-
const classes: { readonly [key: string]: string };
|
|
21
|
-
export default classes;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
declare module '*.css' {
|
|
25
|
-
const classes: { readonly [key: string]: string };
|
|
26
|
-
export default classes;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
declare module '*.sass' {
|
|
30
|
-
const classes: { readonly [key: string]: string };
|
|
31
|
-
export default classes;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
declare module '*.scss' {
|
|
35
|
-
const classes: { readonly [key: string]: string };
|
|
36
|
-
export default classes;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
declare module '*.mdx' {
|
|
40
|
-
const component: any;
|
|
41
|
-
export default component;
|
|
42
|
-
}
|
package/webpack.aspect.ts
DELETED
package/webpack.bundler.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { BitError } from '@teambit/bit-error';
|
|
2
|
-
import { Bundler, BundlerResult, Target } from '@teambit/bundler';
|
|
3
|
-
import { Logger } from '@teambit/logger';
|
|
4
|
-
import mapSeries from 'p-map-series';
|
|
5
|
-
import { Compiler, Configuration } from 'webpack';
|
|
6
|
-
|
|
7
|
-
export class WebpackBundler implements Bundler {
|
|
8
|
-
constructor(
|
|
9
|
-
/**
|
|
10
|
-
* targets to bundle.
|
|
11
|
-
*/
|
|
12
|
-
private targets: Target[],
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* webpack configuration.
|
|
16
|
-
*/
|
|
17
|
-
private configs: Configuration[],
|
|
18
|
-
|
|
19
|
-
private logger: Logger,
|
|
20
|
-
|
|
21
|
-
private webpack
|
|
22
|
-
) {}
|
|
23
|
-
|
|
24
|
-
async run(): Promise<BundlerResult[]> {
|
|
25
|
-
const startTime = Date.now();
|
|
26
|
-
const compilers = this.configs.map((config: any) => this.webpack(config));
|
|
27
|
-
const longProcessLogger = this.logger.createLongProcessLogger('running Webpack bundler', compilers.length);
|
|
28
|
-
const componentOutput = await mapSeries(compilers, (compiler: Compiler) => {
|
|
29
|
-
const components = this.getComponents(compiler.outputPath);
|
|
30
|
-
longProcessLogger.logProgress(components.map((component) => component.id.toString()).join(', '));
|
|
31
|
-
return new Promise((resolve) => {
|
|
32
|
-
// TODO: split to multiple processes to reduce time and configure concurrent builds.
|
|
33
|
-
// @see https://github.com/trivago/parallel-webpack
|
|
34
|
-
return compiler.run((err, stats) => {
|
|
35
|
-
if (err) {
|
|
36
|
-
return resolve({
|
|
37
|
-
errors: [`${err.toString()}\n${err.stack}`],
|
|
38
|
-
components,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
if (!stats) throw new BitError('unknown build error');
|
|
42
|
-
const info = stats.toJson();
|
|
43
|
-
return resolve({
|
|
44
|
-
errors: info.errors,
|
|
45
|
-
outputPath: stats.compilation.outputOptions.path,
|
|
46
|
-
components,
|
|
47
|
-
warnings: info.warnings,
|
|
48
|
-
startTime,
|
|
49
|
-
endTime: Date.now(),
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
longProcessLogger.end();
|
|
55
|
-
return componentOutput as BundlerResult[];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
private getComponents(outputPath: string) {
|
|
59
|
-
const splitPath = outputPath.split('/');
|
|
60
|
-
splitPath.pop();
|
|
61
|
-
const path = splitPath.join('/');
|
|
62
|
-
const target = this.targets.find((targetCandidate) => {
|
|
63
|
-
return path === targetCandidate.outputPath;
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
if (!target) {
|
|
67
|
-
throw new Error(`Could not find component id for path "${path}"`);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return target.components;
|
|
71
|
-
}
|
|
72
|
-
}
|
package/webpack.composition.tsx
DELETED
package/webpack.dev-server.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { DevServer } from '@teambit/bundler';
|
|
2
|
-
import type { Server } from 'http';
|
|
3
|
-
import type { webpack as webpackCompiler, Configuration } from 'webpack';
|
|
4
|
-
import type * as WDS from 'webpack-dev-server';
|
|
5
|
-
import { inspect } from 'util';
|
|
6
|
-
import { WebpackAspect } from './webpack.aspect';
|
|
7
|
-
|
|
8
|
-
export interface WebpackConfigWithDevServer extends Configuration {
|
|
9
|
-
devServer: WDS.Configuration;
|
|
10
|
-
}
|
|
11
|
-
export class WebpackDevServer implements DevServer {
|
|
12
|
-
constructor(
|
|
13
|
-
private config: WebpackConfigWithDevServer,
|
|
14
|
-
private webpack: typeof webpackCompiler,
|
|
15
|
-
private WsDevServer: WDS
|
|
16
|
-
) {}
|
|
17
|
-
|
|
18
|
-
private getCompiler(): any {
|
|
19
|
-
return this.webpack(this.config);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
id = WebpackAspect.id;
|
|
23
|
-
|
|
24
|
-
displayName = 'Webpack dev server';
|
|
25
|
-
|
|
26
|
-
displayConfig(): string {
|
|
27
|
-
return inspect(this.config, { depth: 10 });
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async listen(port: number): Promise<Server> {
|
|
31
|
-
if (!this.config.devServer) {
|
|
32
|
-
throw new Error('Missing devServer configuration for webpack');
|
|
33
|
-
}
|
|
34
|
-
// Prevent different port between the config port and the listen arg port
|
|
35
|
-
this.config.devServer.port = port;
|
|
36
|
-
|
|
37
|
-
// Adding signal listeners to make sure we immediately close the process on sigint / sigterm (otherwise webpack dev server closing will take time)
|
|
38
|
-
this.addSignalListener();
|
|
39
|
-
|
|
40
|
-
// Compatibility check for Webpack dev server v3 (e.g. for Angular v8)
|
|
41
|
-
if (typeof (this.WsDevServer as any).addDevServerEntrypoints !== 'undefined') {
|
|
42
|
-
// @ts-ignore in the capsules it throws an error about compatibilities issues between webpack.compiler and webpackDevServer/webpack/compiler
|
|
43
|
-
const webpackDs = new (this.WsDevServer as any)(this.getCompiler(), this.config.devServer);
|
|
44
|
-
return webpackDs.listen(port);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// @ts-ignore in the capsules it throws an error about compatibilities issues between webpack.compiler and webpackDevServer/webpack/compiler
|
|
48
|
-
const webpackDs: WDS = new this.WsDevServer(this.config.devServer, this.getCompiler());
|
|
49
|
-
await webpackDs.start();
|
|
50
|
-
|
|
51
|
-
return webpackDs.server;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
private addSignalListener() {
|
|
55
|
-
process.on('SIGTERM', () => {
|
|
56
|
-
process.exit();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
process.on('SIGINT', () => {
|
|
60
|
-
process.exit();
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
package/webpack.main.runtime.ts
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import webpack, { Configuration } from 'webpack';
|
|
2
|
-
import PubsubAspect, { PubsubMain } from '@teambit/pubsub';
|
|
3
|
-
import {
|
|
4
|
-
BundlerAspect,
|
|
5
|
-
BundlerContext,
|
|
6
|
-
BundlerMain,
|
|
7
|
-
DevServer,
|
|
8
|
-
DevServerContext,
|
|
9
|
-
BundlerMode,
|
|
10
|
-
Target,
|
|
11
|
-
} from '@teambit/bundler';
|
|
12
|
-
import { MainRuntime } from '@teambit/cli';
|
|
13
|
-
import { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';
|
|
14
|
-
import { Workspace, WorkspaceAspect } from '@teambit/workspace';
|
|
15
|
-
import { merge } from 'webpack-merge';
|
|
16
|
-
import WsDevServer from 'webpack-dev-server';
|
|
17
|
-
import { WebpackConfigMutator } from '@teambit/webpack.modules.config-mutator';
|
|
18
|
-
|
|
19
|
-
import { configFactory as devServerConfigFactory } from './config/webpack.dev.config';
|
|
20
|
-
import { previewConfigFactory } from './config/webpack-preview.config';
|
|
21
|
-
import { configFactory as baseConfigFactory } from './config/webpack.config';
|
|
22
|
-
|
|
23
|
-
import { WebpackAspect } from './webpack.aspect';
|
|
24
|
-
import { WebpackBundler } from './webpack.bundler';
|
|
25
|
-
import { WebpackDevServer } from './webpack.dev-server';
|
|
26
|
-
|
|
27
|
-
export type WebpackConfigTransformContext = GlobalWebpackConfigTransformContext & {
|
|
28
|
-
target: Target;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type WebpackConfigDevServerTransformContext = GlobalWebpackConfigTransformContext;
|
|
32
|
-
|
|
33
|
-
export type GlobalWebpackConfigTransformContext = {
|
|
34
|
-
mode: BundlerMode;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export type WebpackConfigTransformer = (
|
|
38
|
-
config: WebpackConfigMutator,
|
|
39
|
-
context: WebpackConfigTransformContext
|
|
40
|
-
) => WebpackConfigMutator;
|
|
41
|
-
|
|
42
|
-
export type WebpackConfigDevServerTransformer = (
|
|
43
|
-
config: WebpackConfigMutator,
|
|
44
|
-
context: WebpackConfigDevServerTransformContext
|
|
45
|
-
) => WebpackConfigMutator;
|
|
46
|
-
|
|
47
|
-
export class WebpackMain {
|
|
48
|
-
constructor(
|
|
49
|
-
/**
|
|
50
|
-
* Pubsub extension.
|
|
51
|
-
*/
|
|
52
|
-
public pubsub: PubsubMain,
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* workspace extension.
|
|
56
|
-
*/
|
|
57
|
-
private workspace: Workspace,
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* bundler extension.
|
|
61
|
-
*/
|
|
62
|
-
private bundler: BundlerMain,
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Logger extension
|
|
66
|
-
*/
|
|
67
|
-
public logger: Logger
|
|
68
|
-
) {}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* create an instance of bit-compliant webpack dev server for a set of components
|
|
72
|
-
*/
|
|
73
|
-
createDevServer(context: DevServerContext, transformers: WebpackConfigTransformer[] = []): DevServer {
|
|
74
|
-
const config = this.createDevServerConfig(
|
|
75
|
-
context.entry,
|
|
76
|
-
this.workspace.path,
|
|
77
|
-
context.id,
|
|
78
|
-
context.rootPath,
|
|
79
|
-
context.publicPath,
|
|
80
|
-
context.title
|
|
81
|
-
) as any;
|
|
82
|
-
const configMutator = new WebpackConfigMutator(config);
|
|
83
|
-
const transformerContext: GlobalWebpackConfigTransformContext = { mode: 'dev' };
|
|
84
|
-
const afterMutation = runTransformersWithContext(configMutator.clone(), transformers, transformerContext);
|
|
85
|
-
// @ts-ignore - fix this
|
|
86
|
-
return new WebpackDevServer(afterMutation.raw, webpack, WsDevServer);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
mergeConfig(target: any, source: any): any {
|
|
90
|
-
return merge(target, source);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
createBundler(
|
|
94
|
-
context: BundlerContext,
|
|
95
|
-
transformers: WebpackConfigTransformer[] = [],
|
|
96
|
-
initialConfigs?: webpack.Configuration[]
|
|
97
|
-
) {
|
|
98
|
-
const transformerContext: GlobalWebpackConfigTransformContext = { mode: 'prod' };
|
|
99
|
-
const configs = initialConfigs || this.createEmptyConfigs(context.targets, transformers, transformerContext);
|
|
100
|
-
return new WebpackBundler(context.targets, configs, this.logger, webpack);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
createPreviewBundler(context: BundlerContext, transformers: WebpackConfigTransformer[] = []) {
|
|
104
|
-
const transformerContext: GlobalWebpackConfigTransformContext = { mode: 'prod' };
|
|
105
|
-
const configs = this.createPreviewConfig(context.targets, transformers, transformerContext);
|
|
106
|
-
return new WebpackBundler(context.targets, configs, this.logger, webpack);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
private createConfigs(
|
|
110
|
-
targets: Target[],
|
|
111
|
-
factory: (entries: string[], outputPath: string) => Configuration,
|
|
112
|
-
transformers: WebpackConfigTransformer[] = [],
|
|
113
|
-
transformerContext: GlobalWebpackConfigTransformContext
|
|
114
|
-
) {
|
|
115
|
-
return targets.map((target) => {
|
|
116
|
-
const baseConfig = factory(target.entries, target.outputPath);
|
|
117
|
-
const configMutator = new WebpackConfigMutator(baseConfig);
|
|
118
|
-
const context = Object.assign({}, transformerContext, { target });
|
|
119
|
-
const afterMutation = runTransformersWithContext(configMutator.clone(), transformers, context);
|
|
120
|
-
return afterMutation.raw;
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
private createEmptyConfigs(
|
|
125
|
-
targets: Target[],
|
|
126
|
-
transformers: WebpackConfigTransformer[] = [],
|
|
127
|
-
transformerContext: GlobalWebpackConfigTransformContext
|
|
128
|
-
) {
|
|
129
|
-
return this.createConfigs(targets, baseConfigFactory, transformers, transformerContext);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
private createPreviewConfig(
|
|
133
|
-
targets: Target[],
|
|
134
|
-
transformers: WebpackConfigTransformer[] = [],
|
|
135
|
-
transformerContext: GlobalWebpackConfigTransformContext
|
|
136
|
-
) {
|
|
137
|
-
return this.createConfigs(targets, previewConfigFactory, transformers, transformerContext);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
private createDevServerConfig(
|
|
141
|
-
entry: string[],
|
|
142
|
-
rootPath: string,
|
|
143
|
-
devServerID: string,
|
|
144
|
-
publicRoot: string,
|
|
145
|
-
publicPath: string,
|
|
146
|
-
title?: string
|
|
147
|
-
) {
|
|
148
|
-
return devServerConfigFactory(devServerID, rootPath, entry, publicRoot, publicPath, this.pubsub, title);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
static slots = [];
|
|
152
|
-
|
|
153
|
-
static runtime = MainRuntime;
|
|
154
|
-
static dependencies = [PubsubAspect, WorkspaceAspect, BundlerAspect, LoggerAspect];
|
|
155
|
-
|
|
156
|
-
static async provider([pubsub, workspace, bundler, logger]: [PubsubMain, Workspace, BundlerMain, LoggerMain]) {
|
|
157
|
-
const logPublisher = logger.createLogger(WebpackAspect.id);
|
|
158
|
-
return new WebpackMain(pubsub, workspace, bundler, logPublisher);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
WebpackAspect.addRuntime(WebpackMain);
|
|
163
|
-
|
|
164
|
-
export function runTransformersWithContext(
|
|
165
|
-
config: WebpackConfigMutator,
|
|
166
|
-
transformers: Array<WebpackConfigTransformer | WebpackConfigDevServerTransformer> = [],
|
|
167
|
-
context: WebpackConfigTransformContext | WebpackConfigDevServerTransformContext
|
|
168
|
-
): WebpackConfigMutator {
|
|
169
|
-
if (!Array.isArray(transformers)) return config;
|
|
170
|
-
const newConfig = transformers.reduce((acc, transformer) => {
|
|
171
|
-
// @ts-ignore
|
|
172
|
-
return transformer(acc, context);
|
|
173
|
-
}, config);
|
|
174
|
-
return newConfig;
|
|
175
|
-
}
|