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

Relative paths in source maps #93

Closed
byelims opened this issue Jul 27, 2015 · 9 comments
Closed

Relative paths in source maps #93

byelims opened this issue Jul 27, 2015 · 9 comments

Comments

@byelims
Copy link

byelims commented Jul 27, 2015

I'm trying to switch from jsx-loader. My webpack.config.js is like this:

module.exports = {
  entry: './src/javascript/main.jsx',
  output: {
    devtoolModuleFilenameTemplate: '[resource-path]',
    path: './public/js/',
    filename: 'bundle.js'
  },
  module: {
    loaders: [
      { test: /\.jsx$/, loaders: ['jsx'] }
    ]
  }
};

This will produce relative paths in source maps.

{
  sources: ["./src/javascript/main.jsx"]
}

If I use babel-loader with the same config, it will produce absolute paths.

{
  sources: ["/full/path/src/javascript/main.jsx"]
}

Are there any methods to solve this problem?

@waeljammal
Copy link

I second this, it's not nice having full paths..

@nielssj
Copy link

nielssj commented Nov 4, 2015

Agreed, I experience the same issue.
The incorrect paths seem to break the WebStorm debugger.

@elektronik2k5
Copy link

+1

@winseros
Copy link

Same here, babel-loader v.6.2.0

mischkl added a commit to mischkl/babel-loader that referenced this issue Apr 5, 2016
@mischkl
Copy link

mischkl commented Apr 5, 2016

I came up with a simple fix that should solve the problem - check it out.

mischkl added a commit to mischkl/babel-loader that referenced this issue Apr 5, 2016
mischkl added a commit to mischkl/babel-loader that referenced this issue Apr 5, 2016
@danez
Copy link
Member

danez commented Nov 8, 2016

Is this still a problem?

when I try to reproduce the sources look like this: "./fixtures/constant.js"

@dizel3d
Copy link

dizel3d commented Dec 1, 2016

Invalid absolute resource paths are the reason.
babel-core@6.18.2
webpack@2.1.0-beta.27
image

@chrisnicola
Copy link

Just noticed this may be a duplicate of the issue I just filed #480

chrisnicola added a commit to chrisnicola/babel-loader that referenced this issue Jun 24, 2017
babel-loader was setting `options.sourceFileName` to a relative path,
but this does not seem to work correctly anymore with either webpack or
babel itself and causes incorrect source map file data in webpack.

Setting it to an absolute path seems to fix the problem.

Fixes babel#480 and possibly also babel#93.
chrisnicola added a commit to chrisnicola/babel-loader that referenced this issue Jun 26, 2017
babel-loader was setting `options.sourceFileName` to a relative path,
but this does not seem to work correctly anymore with either webpack or
babel itself and causes incorrect source map file data in webpack.

Setting it to an absolute path seems to fix the problem.

Fixes babel#480 and possibly also babel#93.
chrisnicola added a commit to chrisnicola/babel-loader that referenced this issue Jun 26, 2017
babel-loader was setting `options.sourceFileName` to a relative path,
but this does not seem to work correctly anymore with either webpack or
babel itself and causes incorrect source map file data in webpack.

Setting it to an absolute path seems to fix the problem.

Fixes babel#480 and possibly also babel#93.
@hiradyazdan
Copy link

@byelims you probably need to check whether in your .babelrc your babel presets for production env is different (e.g. if using react it's not react-hmre) than your development.

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

No branches or pull requests