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

Fix sourceMappingURL for bundles with multiple entry points #2645

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1 @@
console.log('hello1');
@@ -0,0 +1 @@
console.log('hello2');
@@ -0,0 +1 @@
console.log('hello');
30 changes: 30 additions & 0 deletions packages/core/integration-tests/test/sourcemaps.js
Expand Up @@ -314,4 +314,34 @@ describe('sourcemaps', function() {
);
mapValidator(jsOutput, map);
});

it('should create correct sourceMappingURL', async function() {
const b = await bundle(
path.join(__dirname, '/integration/sourcemap-sourcemappingurl/index.js')
);

const jsOutput = await fs.readFile(b.name, 'utf8');
assert(jsOutput.includes('//# sourceMappingURL=/index.js.map'));
});

it('should create correct sourceMappingURL with multiple entrypoints', async function() {
const b = await bundle([
path.join(
__dirname,
'/integration/sourcemap-sourcemappingurl-multiple-entrypoints/a/index.js'
),
path.join(
__dirname,
'/integration/sourcemap-sourcemappingurl-multiple-entrypoints/b/index.js'
)
]);

const bundle1 = [...b.childBundles][0];
const bundle2 = [...b.childBundles][1];
const jsOutput1 = await fs.readFile(bundle1.name, 'utf8');
const jsOutput2 = await fs.readFile(bundle2.name, 'utf8');

assert(jsOutput1.includes('//# sourceMappingURL=/a/index.js.map'));
assert(jsOutput2.includes('//# sourceMappingURL=/b/index.js.map'));
});
});
2 changes: 1 addition & 1 deletion packages/core/parcel-bundler/src/packagers/JSPackager.js
Expand Up @@ -239,7 +239,7 @@ class JSPackager extends Packager {
if (mapBundle) {
let mapUrl = urlJoin(
this.options.publicURL,
path.basename(mapBundle.name)
path.relative(this.options.outDir, mapBundle.name)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only change is here, rest are tests

);
await this.write(`\n//# sourceMappingURL=${mapUrl}`);
}
Expand Down