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

Comments

Projects
None yet
5 participants
@philipwalton
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@montogeek

montogeek Aug 21, 2018

Member

Not sure this is even supported.

Member

montogeek commented Aug 21, 2018

Not sure this is even supported.

@montogeek

This comment has been minimized.

Show comment
Hide comment
@montogeek

montogeek Aug 21, 2018

Member

Which source map options have you tried?

Member

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

This comment has been minimized.

Show comment
Hide comment
@mathiasbynens

mathiasbynens Aug 21, 2018

Contributor

.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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@philipwalton

philipwalton Aug 21, 2018

Contributor

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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@sokra

sokra Aug 22, 2018

Member

Send a PR fixing this RegExp:

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

Member

sokra commented Aug 22, 2018

Send a PR fixing this RegExp:

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

@philipwalton

This comment has been minimized.

Show comment
Hide comment
@philipwalton

philipwalton Aug 23, 2018

Contributor

Filed #7947.

Contributor

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