Webpack-encore: Strange code analyzing of webpack.config.js in PhpStorm

Created on 3 Aug 2020  路  12Comments  路  Source: symfony/webpack-encore

Hi!

I have fresh installation of webpack-encore-bundle and it works fine, but I see some strange things when I open webpack.config.js in PhpStorm.

Some methods of Encore object (like isRuntimeEnvironmentConfigured(), configureRuntimeEnvironment(), setOutputPath()) are highlighted as unresolved, but some others (setPublicPath(), addEntry()) are resolved correctly:

image

The strangest thing is that if I swap setOutputPath() and setPublicPath(), so after that setPublicPath() becomes unresolved (was resolved) and setOutputPath() is resolved (was unresolved):

image

Windows 10 x64 1909
PhpStorm 2020.2 (JavaScript version is set to ECMAScript 6+ in settings)
Node.JS 14.7.0
Installed devDependencies:

"@symfony/webpack-encore": "^0.30.0",
"core-js": "^3.0.0",
"regenerator-runtime": "^0.13.2",
"webpack-notifier": "^1.6.0"

This issue is very similar to #151 and #236, but I didn't find the solution there.

Most helpful comment

It seems everything is fine after updating to PhpStorm 2020.3, as the JetBrains staff said before on Tracker. So this issue may be closed.

All 12 comments

My analysis would be that direct calls on Encore are marked as unresolved, while chained calls are marked as resolved (or maybe as unknown due to the unresolved calls).

I just tried that. PHPStorm 2020.1 was working fine. After upgrading to PHPStorm 2020.2, I get this issue as well. So I would say that this is a PHPStorm issue rather than a webpack-encore one.

I would say that the new version of PHPStorm does not recognize the type annotation of the export anymore: https://github.com/symfony/webpack-encore/blob/4038860f8c34da1db4e22b4461d88690ba6bc030/index.js#L1650-L1655

@stof It seems PhpStorm 2020.2 can still recognize the type annotation for export:

image

But it can't use it later, in code expressions.
I've just found workaround to fix code highlighting and autocompletion (by calling getEncore()):

image

But it doesn't look perfect. It seems it's time to create an issue on PhpStorm/WebStorm tracker.

This definitely look like a bug in PhpStorm/WebStorm if using such callback works

The issue on PhpStorm Tracker: https://youtrack.jetbrains.com/issue/WI-54625

thanks for doing that report.

just add doc over Encore require
image

@Alphamplyer I tried this yet before writing my previous post and caught strange behavior. When I add @type everything is fine, but after restarting PhpStorm this doesn't work: only removing @type and bringing it back returns code analysis and autocompletion. But this solution is not for me as it requires additional action every time.

I'm agree, that's a temporary solution.

@yura3d Thanks for the report on PhpStorm Tracker.
It seems they are waiting for an answer from you, they want a repo with the issue. So I created a basic one.
Since it's your issue on their tracker they may need only you to answer.
You can use this repo: https://github.com/zek0faws/phpstorm-webpack-encore-issue

Hope that help.

@zek0faws Thank you so much, I haven't enough time last months to make it by myself, so it's cool that you've done it. I've just left a comment about it in PhpStorm tracker.

It seems everything is fine after updating to PhpStorm 2020.3, as the JetBrains staff said before on Tracker. So this issue may be closed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

powerlimit picture powerlimit  路  4Comments

rebangm picture rebangm  路  4Comments

Aerendir picture Aerendir  路  4Comments

MatthD picture MatthD  路  4Comments

EliuTimana picture EliuTimana  路  4Comments