Skip to content

Commit

Permalink
temporarily only running 1 test with debugging for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverryan committed Feb 9, 2021
1 parent 6f79114 commit d3313e0
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 7 deletions.
2 changes: 1 addition & 1 deletion fixtures/js/import_node_modules_image.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// this helps us trigger a manifest.json bug
// https://github.com/shellscape/webpack-manifest-plugin/pull/249
import 'mocha/assets/growl/ok.png';
import '../images/symfony_logo.png';
//import '../images/symfony_logo.png';


// module.userRequest
Expand Down
25 changes: 25 additions & 0 deletions lib/tmpLogger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* This file is part of the Symfony Webpack Encore package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

'use strict';

const fs = require('fs');
const path = require('path');

module.exports = function tmpLogger(data) {
const logPath = path.join(__dirname, '../', 'log.txt');
let contents = '';
if (fs.existsSync(logPath)) {
contents = fs.readFileSync(logPath, 'utf8');
contents += '\n\n';
}

contents += JSON.stringify(data);
fs.writeFileSync(logPath, contents);
};
5 changes: 5 additions & 0 deletions lib/webpack-manifest-plugin/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { dirname, join } = require('path');
const tmpLogger = require('../tmpLogger');

const generateManifest = (compilation, files, { generate, seed = {} }) => {
let result;
Expand Down Expand Up @@ -27,6 +28,10 @@ const getFileType = (fileName, { transformExtensions }) => {
};

const reduceAssets = (files, asset, moduleAssets, assetTypeModuleAssets) => {
tmpLogger({
assetTypeModuleAssets,
sourceFilename: asset.info.sourceFilename,
});
let name;
if (moduleAssets[asset.name]) {
name = moduleAssets[asset.name];
Expand Down
22 changes: 17 additions & 5 deletions lib/webpack-manifest-plugin/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const webpack = require('webpack');
// eslint-disable-next-line global-require
const { RawSource } = webpack.sources || require('webpack-sources');

const tmpLogger = require('../tmpLogger');

const { generateManifest, reduceAssets, reduceChunk, transformFiles } = require('./helpers');

const compilerHookMap = new WeakMap();
Expand Down Expand Up @@ -119,14 +121,24 @@ const normalModuleLoaderHook = ({ moduleAssets, assetTypeModuleAssets }, loaderC
// the "emitFile" callback is never called on asset modules
// so, we create a different map that can be used later in the "emit" hook
if (['asset', 'asset/inline', 'asset/resource', 'asset/source'].includes(module.type)) {
Object.assign(assetTypeModuleAssets, {
const data = {
userRequest: module.userRequest,
rootContext: loaderContext.rootContext
};

tmpLogger(data);

// This takes the userRequest (which is an absolute path) and turns it into
// a relative path to the root context. This is done so that the string
// will match asset.info.sourceFilename in the emit hook.
[relative(loaderContext.rootContext, module.userRequest)]: basename(
module.userRequest
)
});
let sourceFilename = relative(loaderContext.rootContext, module.userRequest);
// at this point, Windows paths use \ in their paths
// but in the emit hook, asset.info.sourceFilename fill have UNIX slashes
sourceFilename = sourceFilename.replace(/\\/g, '/');
tmpLogger({'when': 'after replacing', sourceFilename});
Object.assign(assetTypeModuleAssets, {
[sourceFilename]: basename(module.userRequest),
});
}

// eslint-disable-next-line no-param-reassign
Expand Down
5 changes: 4 additions & 1 deletion test/functional.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ describe('Functional tests using webpack', function() {
});
});

it('Check manifest.json with node_module includes', (done) => {
it.only('Check manifest.json with node_module includes', (done) => {
after(() => {
console.log(fs.readFileSync(path.join(__dirname, '../', 'log.txt'), 'utf8'));
});
const config = createWebpackConfig('web/build', 'dev');
config.addEntry('main', './js/import_node_modules_image');
config.setPublicPath('/build');
Expand Down

0 comments on commit d3313e0

Please sign in to comment.