roman01la / webpack-closure-compiler

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

Source maps not working #37

Closed xdddsheep closed 6 years ago

xdddsheep commented 6 years ago

When I set devtool:"source-map" for webpack with this plugin it does not create a sourcemap.

neodon commented 6 years ago

(I moved this comment from my other account to this one, which is my main GitHub account.)

I'd like to add to this a bit. As far as I can tell this plugin does not do anything with the devtool option. Turns out by setting devtool to source-map in addition to the following option, I was able to get source maps. Yay.

There is an option you can pass to closure compiler to generate sourcemaps:

new ClosureCompilerPlugin({
  compiler: {
    language_in: 'ECMASCRIPT6',
    language_out: 'ECMASCRIPT5',
    compilation_level: 'ADVANCED',
    create_source_map: true
  }
})

It doesn't work though. I receive the following error:

C:\projects\my-project\node_modules\temp\node_modules\rimraf\rimraf.js:137
      throw er
      ^

Error: EPERM: operation not permitted, unlink 'C:\Users\my-user\AppData\Local\Temp\ccwp-dump-117106-5164-4z6kdh.n3s3'
    at Object.fs.unlinkSync (fs.js:1081:18)
    at rimrafSync (C:\projects\my-project\node_modules\temp\node_modules\rimraf\rimraf.js:211:13)
    at cleanupFilesSync (C:\projects\my-project\node_modules\temp\lib\temp.js:88:5)
    at process.cleanupSync (C:\projects\my-project\node_modules\temp\lib\temp.js:195:19)
    at emitOne (events.js:125:13)
    at process.emit (events.js:221:7)
error Command failed with exit code 1.

This particular problem appears to be caused by line 8 of webpack-closure-compiler.js that enables the track feature of the temp module and line 76 which unlinks the temporary file. Since track causes the temp module to clean up after itself, there is a second unlink attempt resulting in the error above.

If you change line 8 to disable the auto cleanup behavior (var temp = require('temp');), the error goes away but the generated source map isn't being copied to the output folder. Commenting out line 76 as well lets you navigate to the temp folder and see what looks like the correct source map.

I realize this could be an error that only shows up on Windows, which is what I am currently using for this work.

I'd like to hear others' thoughts, especially the devs. I can work on a pull request if my understanding of the issue is reasonable.