Skip to content

Commit

Permalink
refactor: code
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Sep 2, 2021
1 parent 95b4c35 commit ed67b60
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
3 changes: 0 additions & 3 deletions examples/magic-html/webpack.config.js
Expand Up @@ -7,9 +7,6 @@ const { setup } = require("../util");
module.exports = setup({
context: __dirname,
entry: "./app.js",
experiments: {
outputModule: true,
},
devServer: {
magicHtml: true,
},
Expand Down
22 changes: 2 additions & 20 deletions lib/Server.js
Expand Up @@ -15,18 +15,6 @@ if (!process.env.WEBPACK_SERVE) {
process.env.WEBPACK_SERVE = true;
}

class AssetsInfoPlugin {
constructor(callback) {
this.callback = callback;
}
// eslint-disable-next-line class-methods-use-this
apply(compiler) {
compiler.hooks.done.tap("assets-info-plugin", (stats) => {
this.callback(stats.compilation.assetsInfo);
});
}
}

class Server {
constructor(options = {}, compiler) {
// TODO: remove this after plugin support is published
Expand Down Expand Up @@ -1080,12 +1068,6 @@ class Server {
plugin.apply(compiler);
}
}

if (this.options.magicHtml) {
new AssetsInfoPlugin((assetsInfo) => {
this.assetsInfo = assetsInfo;
}).apply(this.compiler);
}
});

if (this.options.client && this.options.client.progress) {
Expand Down Expand Up @@ -1962,7 +1944,7 @@ class Server {
const splitOutputFilename = outputFilename.split(".");
let isOutputModule = false;

this.assetsInfo.forEach((value, key) => {
this.stats.compilation.assetsInfo.forEach((value, key) => {
// main.js => ["main", "js"]
// main.another.js => ["main", "another", "js"]
const splitKey = key.split(".");
Expand All @@ -1972,7 +1954,7 @@ class Server {
// If key = main.other.mjs && filename = main.other => true
if (
splitKey.length - 1 === splitOutputFilename.length &&
key.split(".")[0] === outputFilename.split(".")[0]
splitKey[0] === outputFilename.split(".")[0]
) {
extension = splitKey[splitKey.length - 1];
isOutputModule = value.javascriptModule;
Expand Down

0 comments on commit ed67b60

Please sign in to comment.