Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: DeprecationWarning Compilation.assets #677

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions packages/webpack-plugin/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ class LoadablePlugin {
const result = JSON.stringify(stats, null, 2)

if (this.opts.outputAsset) {
hookCompiler.assets[this.opts.filename] = {
source() {
return result
},
size() {
return result.length
},
}
const outputPath = nodePath.resolve(
this.compiler.options.output.path,
this.opts.filename,
)
const file = fs.createWriteStream(outputPath)
file.write(result)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is definitely not a correct way to handle this moment. You should not write file in order to handle deprecation warning, especially if that functionality already exists via writeAssetsFile.

Ask yourself why there were two ways of doing this?

Let's proceed with, which addresses the same problem without removing breaking the contract between loadable and webpack.
https://github.com/gregberge/loadable-components/pull/676/files#diff-ca9a5ec2c1a865ca7d717cfaed22c11c91459fefce687dccc92ca910c1409c5eL32

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file.end()
}

if (this.opts.writeToDisk) {
Expand All @@ -50,7 +49,7 @@ class LoadablePlugin {
* Write Assets Manifest file
* @method writeAssetsFile
*/
writeAssetsFile = manifest => {
writeAssetsFile = (manifest) => {
const outputFolder =
this.opts.writeToDisk.filename || this.compiler.options.output.path

Expand Down