roman01la / webpack-closure-compiler

[DEPRECATED] Google Closure Compiler plugin for Webpack
MIT License
464 stars 25 forks source link

Error when using plugin with webpack-dev-server #46

Open spkirby opened 5 years ago

spkirby commented 5 years ago

OS: Windows 10 Node: v10.16.1 google-closure-compiler: 20190709.0.0 closure-webpack-plugin: 2.0.1 webpack: 4.39.0 webpack-dev-server: 3.7.2

I'm having trouble getting the webpack-closure-compiler plugin working with webpack-dev-server. I've narrowed it down to this basic webpack.config.js file:

const ClosurePlugin = require('closure-webpack-plugin');

module.exports = {
  mode: 'production',
  entry: { main: './src/main.js' },
  plugins: [new ClosurePlugin({mode: 'STANDARD'})]
};

Running webpack outputs the compiled script as expected. However, running npx webpack-dev-server produces the following:

i ?wds?: Project is running at http://localhost:8080/
i ?wds?: webpack output is served from /
i ?wds?: Content not from webpack is served from C:\Users\skirby\Desktop\repro
× ?wdm?: Hash: 78c532b56ca3cdf76c68
Version: webpack 4.39.0
Time: 553ms
Built at: 08/01/2019 5:21:51 PM
 1 asset
Entrypoint main = main.js
 [0] (webpack)-dev-server/client/clients/SockJSClient.js 3.15 KiB {0} [built]
 [3] (webpack)-dev-server/client/utils/log.js 964 bytes {0} [built]
 [4] ./node_modules/querystring-es3/index.js 127 bytes {0} [built]
 [5] multi (webpack)-dev-server/client?http://localhost ./src/main.js 40 bytes {0} [built]
 [6] (webpack)-dev-server/client?http://localhost 4.29 KiB {0} [built]
 [7] (webpack)-dev-server/node_modules/strip-ansi/index.js 161 bytes {0} [built]
 [8] (webpack)-dev-server/node_modules/ansi-regex/index.js 135 bytes {0} [built]
 [9] (webpack)-dev-server/client/socket.js 1.53 KiB {0} [built]
[12] (webpack)-dev-server/client/overlay.js 3.51 KiB {0} [built]
[13] ./node_modules/ansi-html/index.js 4.16 KiB {0} [built]
[18] (webpack)-dev-server/client/utils/sendMessage.js 402 bytes {0} [built]
[19] (webpack)-dev-server/client/utils/reloadApp.js 1.63 KiB {0} [built]
[22] (webpack)-dev-server/client/utils/createSocketUrl.js 2.77 KiB {0} [built]
[30] (webpack)/hot sync nonrecursive ^\.\/log$ 170 bytes {0} [built]
[32] ./src/main.js 30 bytes {0} [built]
    + 18 hidden modules

ERROR in closure-compiler: java.nio.file.InvalidPathException: Illegal char <?> at index 77: C:\Users\skirby\Desktop\repro\node_modules\webpack-dev-server\client\index.js?http://localhost
        at sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
        at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
        at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
        at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
        at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
        at sun.nio.fs.AbstractPath.resolveSibling(AbstractPath.java:66)
        at com.google.javascript.jscomp.SourceMapResolver.getRelativePath(SourceMapResolver.java:102)
        at com.google.javascript.jscomp.Compiler.addSourceMapSourceFiles(Compiler.java:2791)
        at com.google.javascript.jscomp.Compiler.initBasedOnOptions(Compiler.java:527)
        at com.google.javascript.jscomp.Compiler.initModules(Compiler.java:507)
        at com.google.javascript.jscomp.AbstractCommandLineRunner.doRun(AbstractCommandLineRunner.java:1239)
        at com.google.javascript.jscomp.AbstractCommandLineRunner.run(AbstractCommandLineRunner.java:545)
        at com.google.javascript.jscomp.CommandLineRunner.main(CommandLineRunner.java:2158)
i ?wdm?: Failed to compile.

If I disable the ClosurePlugin then webpack-dev-server works as expected.

Admittedly I'm fairly new to Webpack, so apologies if this is an error with my setup.