soundcloud/chunk-manifest-webpack-plugin

1.1.2 outputs .json file instead of .js file

turnerhayes opened this issue ยท 12 comments

It appears that something between 1.1.0 and 1.1.2 has changed the output from a .js file to a .json file. This is what appears in the htmlWebpackPlugin variable in each version:

1.1.0:

{
"files": {
	"publicPath": "/static/",
	"chunks": {
		"webpackManifest": {
			"size": 0,
			"entry": "/static/js/webpackManifest-d41d8cd98f00b204e980.js",
			"hash": "d41d8cd98f00b204e980",
			"css": []
		},
		"vendor": {
			"size": 2626754,
			"entry": "/static/js/vendor-392d99b5276c8459890d.js",
			"hash": "392d99b5276c8459890d",
			"css": [
				"/static/css/vendor-92e4a31a26173772f8ef.css"
			]
		},
		"main": {
			"size": 147201,
			"entry": "/static/js/main-819a8466ef5c6c51cd36.js",
			"hash": "819a8466ef5c6c51cd36",
			"css": [
				"/static/css/main-92e4a31a26173772f8ef.css"
			]
		}
	},
	"js": [
		"/static/js/webpackManifest-d41d8cd98f00b204e980.js",
		"/static/js/vendor-392d99b5276c8459890d.js",
		"/static/js/main-819a8466ef5c6c51cd36.js"
	],
	"css": [
		"/static/css/vendor-92e4a31a26173772f8ef.css",
		"/static/css/main-92e4a31a26173772f8ef.css"
	],
	"webpackManifest": ""
},
"options": {
	"template": "/projects/websites/quintro/node_modules/html-webpack-plugin/lib/loader.js!/projects/websites/quintro/server/views/index.template.ejs",
	"filename": "../server/views/index.hbs",
	"hash": false,
	"inject": false,
	"compile": true,
	"favicon": false,
	"minify": {
		"collapseBooleanAttributes": true,
		"collapseWhitespace": true
	},
	"cache": true,
	"showErrors": true,
	"chunks": "all",
	"excludeChunks": [],
	"title": "Quintro",
	"xhtml": false,
	"alwaysWriteToDisk": true,
	"staticContentURL": "https://localhost:7200"
}
}

1.1.2:

{
"files": {
	"publicPath": "/static/",
	"chunks": {
		"webpackManifest": {
			"size": 0,
			"entry": "/static/webpackManifest.json",
			"hash": "d41d8cd98f00b204e980",
			"css": []
		},
		"vendor": {
			"size": 2626754,
			"entry": "/static/js/vendor-392d99b5276c8459890d.js",
			"hash": "392d99b5276c8459890d",
			"css": [
				"/static/css/vendor-6946c2dfdd053e5b7448.css"
			]
		},
		"main": {
			"size": 147201,
			"entry": "/static/js/main-819a8466ef5c6c51cd36.js",
			"hash": "819a8466ef5c6c51cd36",
			"css": [
				"/static/css/main-6946c2dfdd053e5b7448.css"
			]
		}
	},
	"js": [
		"/static/webpackManifest.json",
		"/static/js/vendor-392d99b5276c8459890d.js",
		"/static/js/main-819a8466ef5c6c51cd36.js"
	],
	"css": [
		"/static/css/vendor-6946c2dfdd053e5b7448.css",
		"/static/css/main-6946c2dfdd053e5b7448.css"
	],
	"webpackManifest": ""
},
"options": {
	"template": "/projects/websites/quintro/node_modules/html-webpack-plugin/lib/loader.js!/projects/websites/quintro/server/views/index.template.ejs",
	"filename": "../server/views/index.hbs",
	"hash": false,
	"inject": false,
	"compile": true,
	"favicon": false,
	"minify": {
		"collapseBooleanAttributes": true,
		"collapseWhitespace": true
	},
	"cache": true,
	"showErrors": true,
	"chunks": "all",
	"excludeChunks": [],
	"title": "Quintro",
	"xhtml": false,
	"alwaysWriteToDisk": true,
	"staticContentURL": "https://localhost:7200"
}
}

Since I have a custom template for HTMLWebpackPlugin that iterates over the js files, this throws an error because it's trying to load a JSON file as a <script src> rather than a .js file.

MildC commented

it also includes the json file on the page even inlineManifest set to false

Same problem here.

Author of https://reactql.org here - same thing is happening in my kit.

Snippet of 1.1.0 (Webpack 2):

<script type="text/javascript" src="/manifest.d41d8cd98f00b204e980.js"></script><script type="text/javascript" src="/vendor.27df1bed7aa4091f008c.js"></script><script type="text/javascript" src="/browser.3f9afcf85183d7fd6943.js"></script></body>
</html>

Now with 1.1.2 (Webpack 3):

<script type="text/javascript" src="/../chunk-manifest.json"></script><script type="text/javascript" src="/vendor.a757c8101d8f95913969.js"></script><script type="text/javascript" src="/browser.3bf79d2a482fc7de3464.js"></script></body>

In the browser:

screen shot 2017-08-06 at 14 50 27

@diurnalist ? @TuckerCowie ? Someone? It's been 23 days this plugin no longer work. You could close this issue, #48, #49 and #50 in one row!

Yes, it's broken after #29.

Is there any motivation to fix this plugin? If #29 introduced the bug, any plans to roll it back?

This one issue renders this plugin defunct.

I don't understand the purpose of that patch, but maybe I'm missing something. Regardless, this also broke our app as well. Will lock version for now, but seems like a rollback is needed.

For those that haven't done this themselves already:
https://www.npmjs.com/package/@codemotion/chunk-manifest-webpack-plugin

Go ahead and paste this in your terminal:

npm uninstall chunk-manifest-webpack-plugin
npm install -D -E @codemotion/chunk-manifest-webpack-plugin

Or if you're using yarn:

yarn remove chunk-manifest-webpack-plugin
yarn add -D -E @codemotion/chunk-manifest-webpack-plugin

And one more thing. Add @codemotion/ in the require statement like so:

const ChunkManifestPlugin = require(`@codemotion/chunk-manifest-webpack-plugin`);

Until this problem gets fixed here I propose that you use the fork I made.

Also if you want any change to the plugin feel free to post an issue/pull request in the repo.

Thanks @DimitarNestorov - very helpful. I'll switch out to your version in the next ReactQL release.

For others who prefer to rely on their own dependencies instead, you can easily fork this project, make the same change as #52, and merge your change into your master branch. Then, in your project that uses chunk-manifest-webpack-plugin, you can install your own fork. i.e.:

$ npm install --save-dev https://github.com/{your-username}/chunk-manifest-webpack-plugin

For example (if you wanted to use my fork),

$ npm install --save-dev https://github.com/sunyang713/chunk-manifest-webpack-plugin

You don't have to change your require statement afterwards; it can remain exactly the same:

// webpack.config.js
. . .
var ChunkManifestPlugin = require('chunk-manifest-webpack-plugin')
. . .

@diurnalist Are there any plans to resolve this issue? People switching to the backup repo is a bad thing as it will be hard to get these people switching back once this issue is resolved...