Skip to content

Commit de9568d

Browse files
committed
Omitting the _tmp_shared from the manifest & entrypoints files
1 parent 049343f commit de9568d

File tree

7 files changed

+36
-4
lines changed

7 files changed

+36
-4
lines changed

lib/config-generator.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const notifierPluginUtil = require('./plugins/notifier');
4040
const sharedEntryConcatPuginUtil = require('./plugins/shared-entry-concat');
4141
const PluginPriorities = require('./plugins/plugin-priorities');
4242
const applyOptionsCallback = require('./utils/apply-options-callback');
43+
const sharedEntryTmpName = require('./utils/sharedEntryTmpName');
4344
const tmp = require('tmp');
4445
const fs = require('fs');
4546
const path = require('path');
@@ -133,7 +134,7 @@ class ConfigGenerator {
133134
`require('${path.resolve(this.webpackConfig.getContext(), this.webpackConfig.sharedCommonsEntryFile)}')`
134135
);
135136

136-
entry._tmp_shared = tmpFileObject.name;
137+
entry[sharedEntryTmpName] = tmpFileObject.name;
137138
}
138139

139140
return entry;

lib/plugins/entry-files-manifest.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
const EntryFilesManifestPlugin = require('../webpack/entry-files-manifest-plugin');
1313
const PluginPriorities = require('./plugin-priorities');
1414
const path = require('path');
15+
const sharedEntryTmpName = require('../utils/sharedEntryTmpName');
1516

1617
/**
1718
* @param {Array} plugins
@@ -22,7 +23,8 @@ module.exports = function(plugins, webpackConfig) {
2223

2324
plugins.push({
2425
plugin: new EntryFilesManifestPlugin(
25-
path.join(webpackConfig.outputPath, 'entrypoints.json')
26+
path.join(webpackConfig.outputPath, 'entrypoints.json'),
27+
[sharedEntryTmpName]
2628
),
2729
priority: PluginPriorities.DeleteUnusedEntriesJSPlugin
2830
});

lib/plugins/manifest.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
const ManifestPlugin = require('webpack-manifest-plugin');
1313
const PluginPriorities = require('./plugin-priorities');
1414
const applyOptionsCallback = require('../utils/apply-options-callback');
15+
const sharedEntryTmpName = require('../utils/sharedEntryTmpName');
1516

1617
/**
1718
* @param {Array} plugins
@@ -30,6 +31,9 @@ module.exports = function(plugins, webpackConfig) {
3031
basePath: manifestPrefix,
3132
// always write a manifest.json file, even with webpack-dev-server
3233
writeToFileEmit: true,
34+
filter: (file) => {
35+
return (!file.isChunk || file.chunk.id !== sharedEntryTmpName);
36+
}
3337
};
3438

3539
plugins.push({

lib/utils/sharedEntryTmpName.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* This file is part of the Symfony Webpack Encore package.
3+
*
4+
* (c) Fabien Potencier <[email protected]>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
10+
'use strict';
11+
12+
module.exports = '_tmp_shared';

lib/webpack/entry-files-manifest-plugin.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
const logger = require('../logger');
1313
const fse = require('fs-extra');
1414

15-
function EntryFilesManifestPlugin(manifestFilename = []) {
15+
function EntryFilesManifestPlugin(manifestFilename, entryNamesToSkip) {
1616
this.manifestFilename = manifestFilename;
17+
this.entryNamesToSkip = entryNamesToSkip;
1718
}
1819

1920
/**
@@ -42,6 +43,10 @@ EntryFilesManifestPlugin.prototype.apply = function(compiler) {
4243
const done = (stats) => {
4344
const entrypoints = {};
4445
stats.compilation.entrypoints.forEach((entry, entryName) => {
46+
if (this.entryNamesToSkip.includes(entryName)) {
47+
return;
48+
}
49+
4550
const { cssFiles, jsFiles } = extractFiles(entry);
4651
entrypoints[entryName] = {
4752
js: jsFiles,

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
const fs = require('fs');
1313
const path = require('path');
14+
const sharedEntryTmpName = require('../utils/sharedEntryTmpName');
1415

1516
function SharedEntryConcatPlugin(sharedEntryName, buildDir) {
1617
this.sharedEntryName = sharedEntryName;
@@ -41,7 +42,7 @@ SharedEntryConcatPlugin.prototype.apply = function(compiler) {
4142
*/
4243

4344
const sharedEntryOutputFile = path.join(this.buildDir, this.sharedEntryName + '.js');
44-
const tmpEntryBootstrapFile = path.join(this.buildDir, '_tmp_shared.js');
45+
const tmpEntryBootstrapFile = path.join(this.buildDir, sharedEntryTmpName + '.js');
4546

4647
if (!fs.existsSync(sharedEntryOutputFile)) {
4748
throw new Error(`Could not find shared entry output file: ${sharedEntryOutputFile}`);

test/functional.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const expect = chai.expect;
1515
const path = require('path');
1616
const testSetup = require('./helpers/setup');
1717
const fs = require('fs-extra');
18+
const sharedEntryTmpName = require('../lib/utils/sharedEntryTmpName');
1819

1920
function createWebpackConfig(outputDirName = '', command, argv = {}) {
2021
return testSetup.createWebpackConfig(
@@ -645,6 +646,12 @@ describe('Functional tests using webpack', function() {
645646
'function __webpack_require__'
646647
);
647648

649+
// make sure the _tmp_shared entry does not live in the manifest
650+
webpackAssert.assertManifestPathDoesNotExist(
651+
sharedEntryTmpName + '.js'
652+
);
653+
webpackAssert.assertOutputFileDoesNotContain('entrypoints.json', sharedEntryTmpName);
654+
648655
testSetup.requestTestPage(
649656
path.join(config.getContext(), 'www'),
650657
[

0 commit comments

Comments
 (0)