-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
5.4.0 Regression: Webpack Compilation Error when browserslist is present in project root #8864
Comments
The problem can be worked around by removing the "browserslist" file and reopening Cypress. But this is not a fix. Don't know how webpack tries to compile the "browserslist" file! |
Having the same issue. I've also worked around it by renaming the browserslists file to .browserslistrc |
I really wish this would emit line numbers/stacktrace. Using eBPF to spy on what is opening the file and getting a stack trace is a bit of a yak shave. DEBUG=cypress:webpack cypress run Confirmed gerardl123's workaround works: git mv browserlists ./browserlistsrc |
I cannot apply this solution. |
I guess it would depend on the application. Mine is an Angular application and I guess the webpack configuration is ok with either browserslist or .browserslistrc file. |
My application is built in angular version 9 Module build failed (from C:/Users/user/AppData/Local/Cypress/Cache/5.4.0/Cypress/resources/app/packages/server/node_modules/babel-loader/lib/index.js):
C:\Users\user\IdeaProjects\project\project-ui\browserslist:1
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
^
SyntaxError: Invalid or unexpected token
at Watching.handle [as handler] (C:\Users\user\AppData\Local\Cypress\Cache\5.4.0\Cypress\resources\app\packages\server\node_modules\@cypress\webpack-preprocessor\dist\index.js:171:23)
at C:\Users\user\AppData\Local\Cypress\Cache\5.4.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Watching.js:99:9
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\user\AppData\Local\Cypress\Cache\5.4.0\Cypress\resources\app\packages\server\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (C:\Users\user\AppData\Local\Cypress\Cache\5.4.0\Cypress\resources\app\packages\server\node_modules\tapable\lib\Hook.js:154:20)
at Watching._done (C:\Users\user\AppData\Local\Cypress\Cache\5.4.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Watching.js:98:28)
at C:\Users\user\AppData\Local\Cypress\Cache\5.4.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Watching.js:73:19
at Compiler.emitRecords (C:\Users\user\AppData\Local\Cypress\Cache\5.4.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Compiler.js:499:39)
at C:\Users\user\AppData\Local\Cypress\Cache\5.4.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Watching.js:54:20
at C:\Users\user\AppData\Local\Cypress\Cache\5.4.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Compiler.js:485:14
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\user\AppData\Local\Cypress\Cache\5.4.0\Cypress\resources\app\packages\server\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (C:\Users\user\AppData\Local\Cypress\Cache\5.4.0\Cypress\resources\app\packages\server\node_modules\tapable\lib\Hook.js:154:20)
at C:\Users\user\AppData\Local\Cypress\Cache\5.4.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Compiler.js:482:27
at C:\Users\user\AppData\Local\Cypress\Cache\5.4.0\Cypress\resources\app\packages\server\node_modules\neo-async\async.js:2818:7
at done (C:\Users\user\AppData\Local\Cypress\Cache\5.4.0\Cypress\resources\app\packages\server\node_modules\neo-async\async.js:3522:9)
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\user\AppData\Local\Cypress\Cache\5.4.0\Cypress\resources\app\packages\server\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (C:\Users\user\AppData\Local\Cypress\Cache\5.4.0\Cypress\resources\app\packages\server\node_modules\tapable\lib\Hook.js:154:20)
at C:\Users\user\AppData\Local\Cypress\Cache\5.4.0\Cypress\resources\app\packages\server\node_modules\webpack\lib\Compiler.js:464:33
at C:\Users\user\AppData\Local\Cypress\Cache\5.4.0\Cypress\resources\app\packages\server\node_modules\graceful-fs\graceful-fs.js:111:16
at C:\Users\user\AppData\Local\Cypress\Cache\5.4.0\Cypress\resources\app\packages\server\node_modules\enhanced-resolve\node_modules\graceful-fs\graceful-fs.js:61:14
at C:\Users\user\AppData\Local\Cypress\Cache\5.4.0\Cypress\resources\app\packages\server\node_modules\graceful-fs\graceful-fs.js:45:10
at FSReqCallback.oncomplete (fs.js:159:23) +11ms
Webpack Compilation Error
|
Can anyone provide a repo that shows this problem? |
@jennifer-shehane Here is a sample project that fails with the mentioned error: It is just an empty Angular 9 project, with [email protected] added. |
Same issue here on angular10. had absolutely no issues with 5.3.0 |
@jennifer-shehane I confirm what @mdunicorn wrote an empty Angular 9 project is enough. |
I have fixed this issue by moving the browser list to package.json |
You mean |
If you are on an Angular project. we give the list of browsers to support which is a file called 'browserlist'. That is the file causing the issue here. So, rather than as a file, we can give those options in package.json like this "browserslist": [
"> 0.5%",
"last 2 versions",
"Firefox ESR",
"not dead",
"not IE 9-11"
], |
Is there any solution for this issue? I'm having the same problem with cypress 5.5.0. I'm guessing that only happens with the las version of cypress because I have another project with 3.8.3 and it work fine. |
I can recreate the issue from the provided repo: https://github.com/mdunicorn/cypress-issue-8864 This is a regression in 5.4.0 and was introduced in this PR: #8826 WorkaroundYou can downgrade to 5.3.0, or follow the directions below.
example package.json {
"scripts": {...},
"dependencies": {...},
"devDependencies": {...},
"browserslist": [
"> 0.5%",
"last 2 versions",
"Firefox ESR",
"not dead",
"not IE 9-11"
]
}
|
@jennifer-shehane - please add the easiest workaround, rename |
TLDR: Just delete the browserslist file. If you take a look inside the browserslist file, there is a link to an external website. There, it states that Cypress will, upon running, try to locate an explicit definition of browserslist from the user. It will try to locate said definition from a variety of sources, failing which it will fall back on a default specification.
My guess is that this browserslist file we have (that was located by Cypress) is invalid because its format is incorrect. This I inferred. My fix to delete this browserslist file hinges on the fact that Cypress will fall back on its own set of (valid) specifications if it fails to obtain a definition from the user. It appears to work. |
Deleting browserslist file is a bad idea, it's used by angular to determine which browsers you want to support, for differential loading, and by other packages as well such as CSS auto-prefixer. Better to rename it to |
The code for this is done in cypress-io/cypress#14754, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior
I get the error when trying to run tests through the Runner:
Desired behavior
The error does not occur.
Test code to reproduce
Cypress update to version 5.4.0
Additionally, what I did to fix the problem:
Versions
Windows 10 64bit
Browser: Chrome 86, FF 81, Electron 85, Edge86
The text was updated successfully, but these errors were encountered: