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

Sourcemap url with multiple entrypoints #2607

Closed
mischnic opened this issue Jan 31, 2019 · 4 comments
Closed

Sourcemap url with multiple entrypoints #2607

mischnic opened this issue Jan 31, 2019 · 4 comments

Comments

@mischnic
Copy link
Member

mischnic commented Jan 31, 2019

🐛 bug report

The sourcemap url in Javascript bundles isn't respecting the subfolder of the corresponding bundle.

🎛 Configuration (.babelrc, package.json, cli command)

parcel build src/a/index.js src/b/index.js

🤔 Expected Behavior

The two output files should contains these sourcemap comments:
a/index.js: //# sourceMappingURL=/a/index.js.map
b/index.js: //# sourceMappingURL=/b/index.js.map

😯 Current Behavior

The two output files contain these sourcemap comments (the map files are emitted correctly though) :
a/index.js: //# sourceMappingURL=/index.js.map
b/index.js: //# sourceMappingURL=/index.js.map

💁 Possible Solution

This is the related code:

let mapBundle = this.bundle.siblingBundlesMap.get('map');
if (mapBundle) {
let mapUrl = urlJoin(
this.options.publicURL,
path.basename(mapBundle.name)
);
await this.write(`\n//# sourceMappingURL=${mapUrl}`);
}

💻 Code Sample

// src/a/index.js
console.log("asd");

// src/b/index.js
console.log("asd");

🌍 Your Environment

Software Version(s)
Parcel master
Node 11
npm/Yarn
Operating System
@lustoykov
Copy link
Contributor

@mischnic you mind me taking this one or you've already started working on it?

On a first thought

path.basename(mapBundle.name) -> path.relative(this.options.outDir, mapBundle.name)

might do it?

@mischnic
Copy link
Member Author

Go ahead. I would say the publicUrl needs to be prepended as well?

@lustoykov
Copy link
Contributor

lustoykov commented Feb 14, 2019

yes, I had in mind:

let mapUrl = urlJoin( 
     this.options.publicURL, 
     path.basename(mapBundle.name) -> path.relative(this.options.outDir, mapBundle.name)
);

will give it a try

@lustoykov
Copy link
Contributor

Can we close, @mischnic?

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

3 participants