Skip to content

Commit 33d81cf

Browse files
committed
refactor(client): make log and strip ansi transpiled bundle modules
1 parent d01ac68 commit 33d81cf

File tree

7 files changed

+59
-3
lines changed

7 files changed

+59
-3
lines changed

client-src/default/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ window.process.env = window.process.env || {};
77

88
/* global __resourceQuery WorkerGlobalScope self */
99
/* eslint prefer-destructuring: off */
10-
const stripAnsi = require('strip-ansi');
10+
const stripAnsi = require('../transpiled-modules/strip-ansi');
1111
const socket = require('./socket');
1212
const overlay = require('./overlay');
1313
const { log, setLogLevel } = require('./utils/log');

client-src/default/utils/log.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const log = require('webpack/lib/logging/runtime');
3+
const log = require('../../transpiled-modules/log');
44

55
const name = 'webpack-dev-server';
66
const defaultLevel = 'info';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict';
2+
3+
module.exports = require('webpack/lib/logging/runtime');
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict';
2+
3+
module.exports = require('strip-ansi');
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
'use strict';
2+
3+
const path = require('path');
4+
const merge = require('webpack-merge');
5+
6+
const base = {
7+
mode: 'production',
8+
output: {
9+
path: path.resolve(__dirname, '../../client/transpiled-modules'),
10+
libraryTarget: 'commonjs2',
11+
},
12+
module: {
13+
rules: [
14+
{
15+
test: /\.js$/,
16+
use: [
17+
{
18+
loader: 'babel-loader',
19+
},
20+
],
21+
},
22+
],
23+
},
24+
};
25+
26+
module.exports = [
27+
merge(base, {
28+
entry: path.join(__dirname, 'log.js'),
29+
output: {
30+
filename: 'log.js',
31+
},
32+
}),
33+
merge(base, {
34+
entry: path.join(__dirname, 'strip-ansi.js'),
35+
output: {
36+
filename: 'strip-ansi.js',
37+
},
38+
}),
39+
];

package-lock.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"build:client:clients": "babel client-src/clients --out-dir client/clients",
3030
"build:client:index": "webpack --color --config client-src/default/webpack.config.js",
3131
"build:client:sockjs": "webpack --color --config client-src/sockjs/webpack.config.js",
32+
"build:client:transpiled-modules": "webpack --color --config client-src/transpiled-modules/webpack.config.js",
3233
"build:client": "rimraf ./client/* && npm-run-all -s -l -p \"build:client:**\"",
3334
"webpack-dev-server": "node examples/run-example.js",
3435
"release": "standard-version"
@@ -109,7 +110,8 @@
109110
"typescript": "^3.9.5",
110111
"url-loader": "^4.1.0",
111112
"webpack": "^4.43.0",
112-
"webpack-cli": "^3.3.11"
113+
"webpack-cli": "^3.3.11",
114+
"webpack-merge": "^4.2.2"
113115
},
114116
"peerDependencies": {
115117
"webpack": "^4.0.0 || ^5.0.0"

0 commit comments

Comments
 (0)