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

Deprecation Warning on Webpack 5 #1126

Closed
artola opened this issue Jun 1, 2020 · 10 comments
Closed

Deprecation Warning on Webpack 5 #1126

artola opened this issue Jun 1, 2020 · 10 comments

Comments

@artola
Copy link

artola commented Jun 1, 2020

Expected Behaviour

Clean output without deprecation warning.

Actual Behaviour

After webpack update (from v4 to v5) I'm getting deprecation warnings in my console.

(node:7361) [DEP_WEBPACK_DEPRECATION_ARRAY_TO_SET] DeprecationWarning: Compilation.modules was changed from Array to Set (using Array method 'reduce' is deprecated)

(node:41349) [DEP_WEBPACK_MODULE_ERRORS] DeprecationWarning: Module.errors was removed (use getErrors instead)

Steps to Reproduce the Problem

Using tracing:

node --trace-deprecation node_modules/webpack/bin/webpack.js

Output:

(node:41650) [DEP_WEBPACK_DEPRECATION_ARRAY_TO_SET] DeprecationWarning: Compilation.modules was changed from Array to Set (using Array method 'reduce' is deprecated)
    at Set.set.<computed> [as reduce] (/Users/.../myproject/node_modules/webpack/lib/util/deprecation.js:78:4)
    at determineModules (/Users/.../myproject/node_modules/ts-loader/dist/after-compile.js:58:32)
(node:41650) [DEP_WEBPACK_MODULE_ERRORS] DeprecationWarning: Module.errors was removed (use getErrors instead)
    at /Users/.../myproject/node_modules/ts-loader/dist/after-compile.js:140:45
    at Array.forEach (<anonymous>)

Environment

Node.js v12.16.2
webpack@5.0.0-beta.16
ts-loader@7.0.5
@telamonian
Copy link

I'm seeing the same as @artola, and one more (latest webpack, 5.0.0-beta.17):

$ node --trace-deprecation node_modules/webpack/bin/webpack.js

(node:9769) [DEP_WEBPACK_DEPRECATION_ARRAY_TO_SET] DeprecationWarning: Compilation.modules was changed from Array to Set (using Array method 'reduce' is deprecated)
    at Set.set.<computed> [as reduce] (.../node_modules/webpack/lib/util/deprecation.js:78:4)
    at determineModules (.../node_modules/ts-loader/dist/after-compile.js:58:32)
...

(node:9769) [DEP_WEBPACK_MODULE_ERRORS] DeprecationWarning: Module.errors was removed (use getErrors instead)
    at .../node_modules/ts-loader/dist/after-compile.js:140:45
...

(node:9769) [DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.
    at outputFileToAsset (.../node_modules/ts-loader/dist/after-compile.js:203:35)
...

@johnnyreilly
Copy link
Member

Thanks - if someone would like to work on this I'll happily review the PR 🤗

@artola
Copy link
Author

artola commented Jun 15, 2020

For warning regarding Array changed to Set, it might be so simple as replace by return Array.from(compilation.modules).reduce, see here:

return compilation.modules.reduce<Map<string, WebpackModule[]>>(

@g-plane
Copy link
Contributor

g-plane commented Jun 30, 2020

I'd like to help, however when I'm inspecting the codebase of ts-loader, I've noticed the usage of errors property:

removeTSLoaderErrors(compilation.errors);

Can anyone tell me why this needs to remove the errors? In fact, this removal should cause no effects on webpack 5, since every time we retrieve the errors property we will get a copied array, and we can't modify the original errors.

@johnnyreilly
Copy link
Member

If memory serves (and it may not) this removes errors registered by ts-loader from a previous run, so the full set of current ts-loader errors can be registered without creating duplicates. Make sense?

@g-plane
Copy link
Contributor

g-plane commented Jul 4, 2020

I've created a PR #1135 , but I don't know why CI would fail.

@johnnyreilly
Copy link
Member

@sheetalkamat has a PR which drops support for older versions of TypeScript here: #1136

When that's merged we can take a look at your PR - it only seems to be failing on older versions of TypeScript.

@woss
Copy link

woss commented Sep 20, 2020

i'm still getting this for the versions:

"ts-node": "^8.10.2",
"typescript": "^4.0.2",
"webpack": "^5.0.0-beta.32",

the command is
clear; node --trace-deprecation ../../node_modules/webpack/bin/webpack.js --mode=development --config webpack.dev.js since this is lerna monorepo and actual webpack is in the root

After reading comments here and other links, i couldn't figure out what is actual solution. is there anything i can do? are my package versions incompatible

@a9udn9u
Copy link

a9udn9u commented Oct 15, 2020

Still getting the error.

$ node --trace-deprecation $NODE_PATH/webpack/bin/webpack.js
(node:12788) [DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
	Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
	Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.
    at outputFileToAsset (/usr/local/lib/node_modules/ts-loader/dist/after-compile.js:216:35)
    at outputFilesToAsset (/usr/local/lib/node_modules/ts-loader/dist/after-compile.js:224:13)
    at addDeclarationFilesAsAsset (/usr/local/lib/node_modules/ts-loader/dist/after-compile.js:210:5)
    at provideDeclarationFilesToWebpack (/usr/local/lib/node_modules/ts-loader/dist/after-compile.js:206:9)
    at /usr/local/lib/node_modules/ts-loader/dist/after-compile.js:30:9
    at Hook.eval [as callAsync] (eval at create (/usr/local/lib/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:7:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/usr/local/lib/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
    at /usr/local/lib/node_modules/webpack/lib/Compiler.js:986:33
    at /usr/local/lib/node_modules/webpack/lib/Compilation.js:2025:10
    at Hook.eval [as callAsync] (eval at create (/usr/local/lib/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
$ webpack --version
webpack-cli 4.0.0
webpack 5.1.0

$ cat $NODE_PATH/ts-loader/package.json | grep '"version"'
  "version": "8.0.5"

@johnnyreilly
Copy link
Member

Some deprecations have been fixed - some still need to be. All help appreciated! Locking this issue - please continue conversation here instead: #1196

@TypeStrong TypeStrong locked as resolved and limited conversation to collaborators Oct 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants