Skip to content

Commit 42ec9ef

Browse files
committed
Using a static, not random filename for the _tmp_shared entry
This small, internal change was causing the final output code to be *slightly* different.
1 parent c2ba1d6 commit 42ec9ef

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/config-generator.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const path = require('path');
4848
const stringEscaper = require('./utils/string-escaper');
4949
const crypto = require('crypto');
5050
const logger = require('./logger');
51+
const os = require('os');
5152

5253
class ConfigGenerator {
5354
/**
@@ -131,14 +132,19 @@ class ConfigGenerator {
131132
*
132133
* See shared-entry-concat-plugin.js for more details.
133134
*/
134-
const tmpFileObject = tmp.fileSync();
135+
const staticHashKey = crypto
136+
.createHash('md4')
137+
.update(this.webpackConfig.outputPath)
138+
.digest('hex')
139+
.slice(0, 8);
140+
const tmpFilename = path.join(os.tmpdir(), '_webpack_encore_tmp_module' + staticHashKey + '.js');
135141
const pathToRequire = path.resolve(this.webpackConfig.getContext(), this.webpackConfig.sharedCommonsEntryFile);
136142
fs.writeFileSync(
137-
tmpFileObject.name,
143+
tmpFilename,
138144
`require('${stringEscaper(pathToRequire)}')`
139145
);
140146

141-
entry[sharedEntryTmpName] = tmpFileObject.name;
147+
entry[sharedEntryTmpName] = tmpFilename;
142148
}
143149

144150
if (this.webpackConfig.copyFilesConfigs.length > 0) {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
'use strict';
1111

12-
const fs = require('fs');
1312
const sharedEntryTmpName = require('../utils/sharedEntryTmpName');
1413
const RawSource = require('webpack-sources/lib/RawSource');
1514

0 commit comments

Comments
 (0)