Skip to content

Commit d3313e0

Browse files
committed
temporarily only running 1 test with debugging for Windows
1 parent 6f79114 commit d3313e0

File tree

5 files changed

+52
-7
lines changed

5 files changed

+52
-7
lines changed

fixtures/js/import_node_modules_image.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// this helps us trigger a manifest.json bug
22
// https://github.com/shellscape/webpack-manifest-plugin/pull/249
33
import 'mocha/assets/growl/ok.png';
4-
import '../images/symfony_logo.png';
4+
//import '../images/symfony_logo.png';
55

66

77
// module.userRequest

lib/tmpLogger.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
const fs = require('fs');
13+
const path = require('path');
14+
15+
module.exports = function tmpLogger(data) {
16+
const logPath = path.join(__dirname, '../', 'log.txt');
17+
let contents = '';
18+
if (fs.existsSync(logPath)) {
19+
contents = fs.readFileSync(logPath, 'utf8');
20+
contents += '\n\n';
21+
}
22+
23+
contents += JSON.stringify(data);
24+
fs.writeFileSync(logPath, contents);
25+
};

lib/webpack-manifest-plugin/helpers.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const { dirname, join } = require('path');
2+
const tmpLogger = require('../tmpLogger');
23

34
const generateManifest = (compilation, files, { generate, seed = {} }) => {
45
let result;
@@ -27,6 +28,10 @@ const getFileType = (fileName, { transformExtensions }) => {
2728
};
2829

2930
const reduceAssets = (files, asset, moduleAssets, assetTypeModuleAssets) => {
31+
tmpLogger({
32+
assetTypeModuleAssets,
33+
sourceFilename: asset.info.sourceFilename,
34+
});
3035
let name;
3136
if (moduleAssets[asset.name]) {
3237
name = moduleAssets[asset.name];

lib/webpack-manifest-plugin/hooks.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const webpack = require('webpack');
66
// eslint-disable-next-line global-require
77
const { RawSource } = webpack.sources || require('webpack-sources');
88

9+
const tmpLogger = require('../tmpLogger');
10+
911
const { generateManifest, reduceAssets, reduceChunk, transformFiles } = require('./helpers');
1012

1113
const compilerHookMap = new WeakMap();
@@ -119,14 +121,24 @@ const normalModuleLoaderHook = ({ moduleAssets, assetTypeModuleAssets }, loaderC
119121
// the "emitFile" callback is never called on asset modules
120122
// so, we create a different map that can be used later in the "emit" hook
121123
if (['asset', 'asset/inline', 'asset/resource', 'asset/source'].includes(module.type)) {
122-
Object.assign(assetTypeModuleAssets, {
124+
const data = {
125+
userRequest: module.userRequest,
126+
rootContext: loaderContext.rootContext
127+
};
128+
129+
tmpLogger(data);
130+
123131
// This takes the userRequest (which is an absolute path) and turns it into
124132
// a relative path to the root context. This is done so that the string
125133
// will match asset.info.sourceFilename in the emit hook.
126-
[relative(loaderContext.rootContext, module.userRequest)]: basename(
127-
module.userRequest
128-
)
129-
});
134+
let sourceFilename = relative(loaderContext.rootContext, module.userRequest);
135+
// at this point, Windows paths use \ in their paths
136+
// but in the emit hook, asset.info.sourceFilename fill have UNIX slashes
137+
sourceFilename = sourceFilename.replace(/\\/g, '/');
138+
tmpLogger({'when': 'after replacing', sourceFilename});
139+
Object.assign(assetTypeModuleAssets, {
140+
[sourceFilename]: basename(module.userRequest),
141+
});
130142
}
131143

132144
// eslint-disable-next-line no-param-reassign

test/functional.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ describe('Functional tests using webpack', function() {
152152
});
153153
});
154154

155-
it('Check manifest.json with node_module includes', (done) => {
155+
it.only('Check manifest.json with node_module includes', (done) => {
156+
after(() => {
157+
console.log(fs.readFileSync(path.join(__dirname, '../', 'log.txt'), 'utf8'));
158+
});
156159
const config = createWebpackConfig('web/build', 'dev');
157160
config.addEntry('main', './js/import_node_modules_image');
158161
config.setPublicPath('/build');

0 commit comments

Comments
 (0)