Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source maps aren't added to .mjs output files #7927

Closed
philipwalton opened this issue Aug 21, 2018 · 6 comments
Closed

Source maps aren't added to .mjs output files #7927

philipwalton opened this issue Aug 21, 2018 · 6 comments
Labels

Comments

@philipwalton
Copy link
Contributor

@philipwalton philipwalton commented Aug 21, 2018

Bug report

What is the current behavior?

Source maps don't get added when defining an output file with an mjs extension. If I change nothing about my config except for the output extension from mjs to js, it works as expected.

If the current behavior is a bug, please provide the steps to reproduce.

Here's a minimal repo:

webpack.config.js:

const webpack = require("webpack");
const path = require('path');

module.exports = {
  mode: 'development',
  entry: {
    main: "./main.mjs"
  },
  output: {
    path: path.resolve(__dirname),
    filename: "[name].[chunkhash].mjs",
  },
  devtool: '#source-map',
};

main.mjs:

console.log('Hello World');

Other relevant information:
webpack version: 4.17.0
Node.js version: 10.8
Operating System: MacOS 10.13.6
Additional tools: N/A

@montogeek
Copy link
Member

@montogeek montogeek commented Aug 21, 2018

Not sure this is even supported.

@montogeek
Copy link
Member

@montogeek montogeek commented Aug 21, 2018

Which source map options have you tried?

@montogeek montogeek closed this Aug 21, 2018
@montogeek montogeek reopened this Aug 21, 2018
@mathiasbynens
Copy link
Contributor

@mathiasbynens mathiasbynens commented Aug 21, 2018

.mjs is supported by default elsewhere in webpack. I think applying the same logic (if *.js or *.mjs → generate source maps) would make sense here.

@philipwalton
Copy link
Contributor Author

@philipwalton philipwalton commented Aug 21, 2018

In my example I show that I'm using the option devtool: '#source-map'.

And I agree with @mathiasbynens, Webpack claims in many places that it supports .mjs, and it's able to process the file correctly. The only thing it's not doing is generating the source map and appending a reference to it in the original file.

@sokra
Copy link
Member

@sokra sokra commented Aug 22, 2018

Send a PR fixing this RegExp:

options.test = options.test || /\.(js|css)($|\?)/i;

@philipwalton
Copy link
Contributor Author

@philipwalton philipwalton commented Aug 23, 2018

Filed #7947.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.