Skip to content

Commit bb57c56

Browse files
committed
bug #356 Fix shared entry file when source maps are enabled (Lyrkan)
This PR was merged into the master branch. Discussion ---------- Fix shared entry file when source maps are enabled This PR fixes #352. When source maps are enabled, the original shared entry file ends with a commented line. This is an issue when the "_tmp_shared" entry is appended to it since its first line then becomes part of that comment. Commits ------- 278d992 Fix shared entry file when source maps are enabled
2 parents c247131 + 278d992 commit bb57c56

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lib/webpack/shared-entry-concat-plugin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ SharedEntryConcatPlugin.prototype.apply = function(compiler) {
7272

7373
fs.writeFileSync(
7474
sharedEntryOutputFile,
75-
fs.readFileSync(sharedEntryOutputFile) + fs.readFileSync(tmpEntryBootstrapFile)
75+
[fs.readFileSync(sharedEntryOutputFile), fs.readFileSync(tmpEntryBootstrapFile)].join('\n')
7676
);
7777

7878
fs.unlinkSync(tmpEntryBootstrapFile);

test/functional.js

+24
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,30 @@ describe('Functional tests using webpack', function() {
801801
});
802802
});
803803

804+
it('createdSharedEntry() works with source maps enabled', (done) => {
805+
const config = createWebpackConfig('www/build', 'dev');
806+
config.setPublicPath('/build');
807+
config.addEntry('main', ['./js/no_require', './js/code_splitting', './js/arrow_function', './js/print_to_app']);
808+
config.addEntry('other', ['./js/no_require', './css/h1_style.css']);
809+
config.createSharedEntry('shared', './js/shared_example');
810+
config.enableSourceMaps(true);
811+
812+
testSetup.runWebpack(config, (webpackAssert) => {
813+
testSetup.requestTestPage(
814+
path.join(config.getContext(), 'www'),
815+
[
816+
convertToManifestPath('build/runtime.js', config),
817+
convertToManifestPath('build/shared.js', config),
818+
],
819+
(browser) => {
820+
// assert that the javascript brought into shared is executed
821+
browser.assert.text('#app', 'Welcome to Encore!');
822+
done();
823+
}
824+
);
825+
});
826+
});
827+
804828
it('in production mode, code is uglified', (done) => {
805829
const config = createWebpackConfig('www/build', 'production');
806830
config.setPublicPath('/build');

0 commit comments

Comments
 (0)