Skip to content

Commit

Permalink
refactor(client): make log and strip ansi transpiled bundle modules
Browse files Browse the repository at this point in the history
  • Loading branch information
knagaitsev committed Jun 23, 2020
1 parent d01ac68 commit 33d81cf
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 3 deletions.
2 changes: 1 addition & 1 deletion client-src/default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ window.process.env = window.process.env || {};

/* global __resourceQuery WorkerGlobalScope self */
/* eslint prefer-destructuring: off */
const stripAnsi = require('strip-ansi');
const stripAnsi = require('../transpiled-modules/strip-ansi');
const socket = require('./socket');
const overlay = require('./overlay');
const { log, setLogLevel } = require('./utils/log');
Expand Down
2 changes: 1 addition & 1 deletion client-src/default/utils/log.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

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

const name = 'webpack-dev-server';
const defaultLevel = 'info';
Expand Down
3 changes: 3 additions & 0 deletions client-src/transpiled-modules/log.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = require('webpack/lib/logging/runtime');
3 changes: 3 additions & 0 deletions client-src/transpiled-modules/strip-ansi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = require('strip-ansi');
39 changes: 39 additions & 0 deletions client-src/transpiled-modules/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict';

const path = require('path');
const merge = require('webpack-merge');

const base = {
mode: 'production',
output: {
path: path.resolve(__dirname, '../../client/transpiled-modules'),
libraryTarget: 'commonjs2',
},
module: {
rules: [
{
test: /\.js$/,
use: [
{
loader: 'babel-loader',
},
],
},
],
},
};

module.exports = [
merge(base, {
entry: path.join(__dirname, 'log.js'),
output: {
filename: 'log.js',
},
}),
merge(base, {
entry: path.join(__dirname, 'strip-ansi.js'),
output: {
filename: 'strip-ansi.js',
},
}),
];
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"build:client:clients": "babel client-src/clients --out-dir client/clients",
"build:client:index": "webpack --color --config client-src/default/webpack.config.js",
"build:client:sockjs": "webpack --color --config client-src/sockjs/webpack.config.js",
"build:client:transpiled-modules": "webpack --color --config client-src/transpiled-modules/webpack.config.js",
"build:client": "rimraf ./client/* && npm-run-all -s -l -p \"build:client:**\"",
"webpack-dev-server": "node examples/run-example.js",
"release": "standard-version"
Expand Down Expand Up @@ -109,7 +110,8 @@
"typescript": "^3.9.5",
"url-loader": "^4.1.0",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11"
"webpack-cli": "^3.3.11",
"webpack-merge": "^4.2.2"
},
"peerDependencies": {
"webpack": "^4.0.0 || ^5.0.0"
Expand Down

0 comments on commit 33d81cf

Please sign in to comment.