-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Webpack 5 automatic publicPath error (#23760)
* fix: Webpack 5 automatic publicPath error * update webpack-preprocessor test * fix: disable webpack-preprocessor chunking * stub LimitChunkCountPlugin Co-authored-by: Zachary Williams <zachjw34@gmail.com>
- Loading branch information
Showing
8 changed files
with
1,988 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
system-tests/projects/webpack-preprocessor-webpack-5/cypress.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Since we are linking the `@cypress/webpack-preprocessor` package, | ||
// `require('webpack')` will resolve the version found in our repo (v4). | ||
// We need to override the webpack require to point to the local node_modules | ||
const Module = require('module') | ||
|
||
const originalModuleLoad = Module._load | ||
|
||
Module._load = function (request, parent, isMain) { | ||
if (request === 'webpack' || request.startsWith('webpack/')) { | ||
const resolvePath = require.resolve(request, { | ||
paths: [__dirname], | ||
}) | ||
|
||
return originalModuleLoad(resolvePath, parent, isMain) | ||
} | ||
|
||
return originalModuleLoad(request, parent, isMain) | ||
} | ||
|
||
const { defineConfig } = require('cypress') | ||
const wp = require('@cypress/webpack-preprocessor') | ||
|
||
module.exports = defineConfig({ | ||
e2e: { | ||
supportFile: false, | ||
setupNodeEvents (on, config) { | ||
on('file:preprocessor', wp({ | ||
webpackOptions: { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.m?js$/, | ||
exclude: /node_modules/, | ||
use: { | ||
loader: 'babel-loader', | ||
options: { | ||
presets: [ | ||
['@babel/preset-env', { targets: 'defaults' }], | ||
], | ||
plugins: ['@babel/plugin-transform-runtime'], | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
})) | ||
}, | ||
}, | ||
}) |
5 changes: 5 additions & 0 deletions
5
system-tests/projects/webpack-preprocessor-webpack-5/cypress/e2e/dynamic-import.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
it('should work', async () => { | ||
const { default: lazyModule } = await import('./lazy.js') | ||
|
||
expect(lazyModule.hello).eq('world') | ||
}) |
1 change: 1 addition & 0 deletions
1
system-tests/projects/webpack-preprocessor-webpack-5/cypress/e2e/lazy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default { hello: 'world' } |
10 changes: 10 additions & 0 deletions
10
system-tests/projects/webpack-preprocessor-webpack-5/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"dependencies": { | ||
"@babel/core": "7.19.0", | ||
"@babel/plugin-transform-runtime": "7.18.10", | ||
"@babel/preset-env": "7.19.0", | ||
"@cypress/webpack-preprocessor": "file:../../../npm/webpack-preprocessor", | ||
"babel-loader": "8.2.5", | ||
"webpack": "^5.74.0" | ||
} | ||
} |
1,897 changes: 1,897 additions & 0 deletions
1,897
system-tests/projects/webpack-preprocessor-webpack-5/yarn.lock
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import systemTests from '../lib/system-tests' | ||
|
||
describe('@cypress/webpack-preprocessor', function () { | ||
systemTests.setup() | ||
|
||
systemTests.it('with Webpack 5', { | ||
project: 'webpack-preprocessor-webpack-5', | ||
testingType: 'e2e', | ||
spec: '**/*.cy.js', | ||
browser: 'chrome', | ||
expectedExitCode: 0, | ||
}) | ||
}) |
823ffd0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
823ffd0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux arm64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
823ffd0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin arm64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
823ffd0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
823ffd0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
win32 x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally: