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

chore: update to webpack v5 #27438

Merged
merged 37 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a7c7f8e
chore: [run ci] does further prerequisites for webpack 5:
AtofStryker Jul 28, 2023
d62dac9
chore: upgrade to webpack 5 and do the bare minimum to get it working
AtofStryker Jul 28, 2023
b4cbe0a
chore: get @packages/extension working
AtofStryker Jul 28, 2023
de6a53d
chore: add TODOs to finish after webpack 5 update
AtofStryker Jul 28, 2023
3a152ac
chore: update the webpack config for npm/webpack-batteries-included-p…
AtofStryker Jul 28, 2023
23ff811
chore: patch whatwg-url 7.1.0. package 'source-map' uses
AtofStryker Jul 28, 2023
82a9b73
chore: convert whatwg patch into dev patch as source-map is not insta…
AtofStryker Jul 29, 2023
943912e
chore: only move production level patches into the binary dist direct…
AtofStryker Jul 30, 2023
b723bc4
chore: remove --openssl-legacy-provider code for node versions 17 and…
AtofStryker Jul 28, 2023
09643d9
chore: fix the webpack-batteries-included-preprocessor tests by shimm…
AtofStryker Jul 29, 2023
bcc5f40
chore: provide the define plugin and evalDevtoolPlugin again as we ne…
AtofStryker Aug 1, 2023
3520bc4
chore: updating v8 snapshot cache
Jul 30, 2023
ed6e780
chore: updating v8 snapshot cache
Jul 31, 2023
e49fc37
chore: updating v8 snapshot cache
Jul 31, 2023
b39dae1
chore: fix the webpack preprocessor not to change promise references …
AtofStryker Jul 31, 2023
3e9fa7c
chore: fix issues from readFile that were caused by Webpack 5 using '…
AtofStryker Jul 31, 2023
d445f61
chore: update chrome component testing snapshots to match Webpack 5 c…
AtofStryker Jul 31, 2023
d88f42d
chore: fix mismatched snapshots from webpack 5 update
AtofStryker Jul 31, 2023
6d8400e
chore: use Cypress.Buffer instead of Buffer for selectFile system tes…
AtofStryker Jul 31, 2023
23a42d0
chore: fix system test webpack path that now includes e2e workspace
AtofStryker Jul 31, 2023
89e6089
chore: patch enhanced-resolve to properly discover the pnp api for th…
AtofStryker Jul 31, 2023
3406525
chore: set stats to 'none' for experimentalSingleTabMode to prevent d…
AtofStryker Jul 31, 2023
e62e7dd
chore: fix node built in tests and configure webpack-batteries-includ…
AtofStryker Aug 1, 2023
0445987
chore: fallback to buffer correctly in config, even though there is n…
AtofStryker Aug 1, 2023
e05801a
Update binary-cleanup.js to exclude added build dependencies for webpack
ryanthemanuel Aug 1, 2023
2e39e37
chore: add stream-browserify to webpack preprocessor batteries includ…
AtofStryker Aug 1, 2023
8ad7959
chore: make sure process and buffer are installed in the CLI for webp…
AtofStryker Aug 1, 2023
d8ccfc8
chore: build cross platform binaries [run ci]
AtofStryker Aug 1, 2023
50dbba2
chore: fix webpack evalDevToolPlugin instantiation [run ci]
AtofStryker Aug 1, 2023
14118a2
run all binary jobs [run ci]
AtofStryker Aug 1, 2023
cb5fb4e
chore: updating v8 snapshot cache
Aug 4, 2023
3f0a2d5
add find-up to the entry points that need to be kept
ryanthemanuel Aug 4, 2023
ef87f97
chore: updating v8 snapshot cache
Aug 4, 2023
77d81c2
chore: updating v8 snapshot cache
Aug 5, 2023
a50ebdc
chore: fix mocha build warnings
AtofStryker Aug 2, 2023
dd78d50
chore: fix STRIPPED_INTEGRITY_TAG import warnings
AtofStryker Aug 2, 2023
721d6a5
chore: add changelog event
AtofStryker Aug 7, 2023
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
10 changes: 5 additions & 5 deletions .circleci/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mainBuildFilters: &mainBuildFilters
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- 'update-v8-snapshot-cache-on-develop'
- 'chore/update_webpack_deps_to_latest_webpack4_compat'
- 'chore/use_cloud_m1_runners'
- 'chore/update_to_webpack5_minimum_lift'
- 'publish-binary'

# usually we don't build Mac app - it takes a long time
Expand All @@ -44,7 +44,7 @@ macWorkflowFilters: &darwin-workflow-filters
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
- equal: [ 'chore/update_webpack_deps_to_latest_webpack4_compat', << pipeline.git.branch >> ]
- equal: [ 'chore/use_cloud_m1_runners', << pipeline.git.branch >> ]
- equal: [ 'chore/update_to_webpack5_minimum_lift', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
value: << pipeline.git.branch >>
Expand All @@ -56,7 +56,7 @@ linuxArm64WorkflowFilters: &linux-arm64-workflow-filters
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
- equal: [ 'chore/update_webpack_deps_to_latest_webpack4_compat', << pipeline.git.branch >> ]
- equal: [ 'chore/use_cloud_m1_runners', << pipeline.git.branch >> ]
- equal: [ 'chore/update_to_webpack5_minimum_lift', << pipeline.git.branch >> ]
- equal: [ 'publish-binary', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
Expand All @@ -78,7 +78,7 @@ windowsWorkflowFilters: &windows-workflow-filters
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
- equal: [ 'chore/update_webpack_deps_to_latest_webpack4_compat', << pipeline.git.branch >> ]
- equal: [ 'chore/use_cloud_m1_runners', << pipeline.git.branch >> ]
- equal: [ 'chore/update_to_webpack5_minimum_lift', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
value: << pipeline.git.branch >>
Expand Down Expand Up @@ -148,7 +148,7 @@ commands:
name: Set environment variable to determine whether or not to persist artifacts
command: |
echo "Setting SHOULD_PERSIST_ARTIFACTS variable"
echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "publish-binary" && "$CIRCLE_BRANCH" != "chore/update_webpack_deps_to_latest_webpack4_compat" ]]; then
echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "publish-binary" && "$CIRCLE_BRANCH" != "chore/update_to_webpack5_minimum_lift" ]]; then
export SHOULD_PERSIST_ARTIFACTS=true
fi' >> "$BASH_ENV"
# You must run `setup_should_persist_artifacts` command and be using bash before running this command
Expand Down
4 changes: 4 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ _Released 08/15/2023 (PENDING)_

- Fixed an issue where having `cypress.config` in a nested directory would cause problems with locating the `component-index.html` file when using component testing. Fixes [#26400](https://github.com/cypress-io/cypress/issues/26400).

**Dependency Updates:**

- Upgraded [`webpack`](https://www.npmjs.com/package/webpack) from `v4` to `v5`. This means that we are now bundling your `e2e` tests with webpack 5. We don't anticipate this causing any noticeable changes. However, if you'd like to keep bundling your `e2e` tests with wepback 4 you can use the same process as before by pinning [@cypress/webpack-batteries-included-preprocessor](https://www.npmjs.com/package/@cypress/webpack-batteries-included-preprocessor) to `v2.x.x` and hooking into the [file:preprocessor](https://docs.cypress.io/api/plugins/preprocessors-api#Usage) plugin event. This will restore the previous bundling process. Additionally, if you're using [@cypress/webpack-batteries-included-preprocessor](https://www.npmjs.com/package/@cypress/webpack-batteries-included-preprocessor) already, a new version has been published to support webpack `v5`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Would they also need to install webpack@4 to keep things working the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not in this case because v2 of webpack-batteries-included-preprocesor ships with 4. its not backwards compatible unlike the regular webpack-preprocessor


## 12.17.3

_Released 08/01/2023_
Expand Down
16 changes: 0 additions & 16 deletions cli/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const isInstalledGlobally = require('is-installed-globally')
const logger = require('./logger')
const debug = require('debug')('cypress:cli')
const fs = require('./fs')
const semver = require('semver')

const pkg = require(path.join(__dirname, '..', 'package.json'))

Expand Down Expand Up @@ -305,21 +304,6 @@ const util = {
opts.ORIGINAL_NODE_OPTIONS = process.env.NODE_OPTIONS
}

// https://github.com/cypress-io/cypress/issues/18914
// Node 17+ ships with OpenSSL 3 by default, so we may need the option
// --openssl-legacy-provider so that webpack@4 can use the legacy MD4 hash
// function. This option doesn't exist on Node <17 or when it is built
// against OpenSSL 1, so we have to detect Node's major version and check
// which version of OpenSSL it was built against before spawning the plugins
// process.

// To be removed when the Cypress binary pulls in the @cypress/webpack-batteries-included-preprocessor
// version that has been updated to webpack >= 5.61, which no longer relies on
// Node's builtin crypto.hash function.
if (process.versions && semver.satisfies(process.versions.node, '>=17.0.0') && semver.satisfies(process.versions.openssl, '>=3', { includePrerelease: true })) {
opts.ORIGINAL_NODE_OPTIONS = `${opts.ORIGINAL_NODE_OPTIONS || ''} --openssl-legacy-provider`
}

return opts
},

Expand Down
1 change: 1 addition & 0 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"minimist": "^1.2.8",
"ospath": "^1.2.2",
"pretty-bytes": "^5.6.0",
"process": "^0.11.10",
"proxy-from-env": "1.0.0",
"request-progress": "^3.0.0",
"semver": "^7.5.3",
Expand Down
26 changes: 26 additions & 0 deletions cli/test/lib/tasks/dependency_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* as of Webpack 5, dependencies that are polyfilled through the Provide plugin must be defined inside the CLI
* in order to guarantee there is a version of the dependency accessible by the cypress CLI, either in the cypress directory
* or the root of their project. Currently, these two dependencies are 'buffer' and 'process'
*/
describe('dependencies', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I have some questions about this. If webpack 4 polyfilled all core Node.js libs out of the box, does that mean you could (and can)

  • install cypress 12
  • write a spec that imports fs
  • have it run successfully (eg, fs won't error out)

I haven't tried this yet, but worth considering. I know we don't do this in our code base, but I'm sure some code bases rely on those polyfills (especially crypto).

I wonder if we need to polyfill ALL the core modules to maintain backwards compatibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it depends. fs is probably a bad example here since we intentionally leave it empty in the webpack-batteries-included-preprocessor and don't expect that built in to be available. But for something like crypto for your example, you could do all those steps and it will not error out since we install the polyfill. I think you talked about it in another spot in this PR, but this comment explains it for anyone else reading

it('process dependency exists in package.json and is available', () => {
const { dependencies } = require('../../../package.json')

expect(dependencies.process).to.be.ok

const process = require('process')

expect(typeof process).to.equal('object')
})

it('buffer dependency exists in package.json and is available', () => {
const { dependencies } = require('../../../package.json')

expect(dependencies.buffer).to.be.ok

const buffer = require('buffer')
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we assert that

require('node:buffer') !== require('buffer')

That would verify the Buffer you get is not the core Node.js one. You can use require('node:<module>') to get the core one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that might be a good idea, considering we really want to just make sure the buffer is installed in the package through the package.json and its accessible


expect(typeof buffer).to.equal('object')
})
})
62 changes: 0 additions & 62 deletions cli/test/lib/util_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,68 +278,6 @@ describe('util', () => {
ORIGINAL_NODE_OPTIONS: '--require foo.js',
})
})

// https://github.com/cypress-io/cypress/issues/18914
it('includes --openssl-legacy-provider in Node 17+ w/ OpenSSL 3', () => {
sandbox.stub(process.versions, 'node').value('v17.1.0')
sandbox.stub(process.versions, 'openssl').value('3.0.0-quic')

restoreEnv = mockedEnv({
NODE_OPTIONS: '--require foo.js',
})

let childOptions = util.getOriginalNodeOptions()

expect(childOptions.ORIGINAL_NODE_OPTIONS).to.eq('--require foo.js --openssl-legacy-provider')

restoreEnv()
restoreEnv = mockedEnv({})
childOptions = util.getOriginalNodeOptions()

expect(childOptions.ORIGINAL_NODE_OPTIONS).to.eq(' --openssl-legacy-provider')
})

// https://github.com/cypress-io/cypress/issues/19320
it('does not include --openssl-legacy-provider in Node 17+ w/ OpenSSL 1', () => {
sandbox.stub(process.versions, 'node').value('v17.1.0')
sandbox.stub(process.versions, 'openssl').value('1.0.0')

restoreEnv = mockedEnv({
NODE_OPTIONS: '--require foo.js',
})

let childOptions = util.getOriginalNodeOptions()

expect(childOptions.ORIGINAL_NODE_OPTIONS).to.eq('--require foo.js')
expect(childOptions.ORIGINAL_NODE_OPTIONS).not.to.contain('--openssl-legacy-provider')

restoreEnv()
restoreEnv = mockedEnv({})
childOptions = util.getOriginalNodeOptions()

expect(childOptions.ORIGINAL_NODE_OPTIONS).to.be.undefined
})

// https://github.com/cypress-io/cypress/issues/18914
it('does not include --openssl-legacy-provider in Node <=16', () => {
sandbox.stub(process.versions, 'node').value('v16.14.2')
sandbox.stub(process.versions, 'openssl').value('1.0.0')

restoreEnv = mockedEnv({})

let childOptions = util.getOriginalNodeOptions()

expect(childOptions.ORIGINAL_NODE_OPTIONS).to.be.undefined

restoreEnv = mockedEnv({
NODE_OPTIONS: '--require foo.js',
})

childOptions = util.getOriginalNodeOptions()

expect(childOptions.ORIGINAL_NODE_OPTIONS).to.eq('--require foo.js')
expect(childOptions.ORIGINAL_NODE_OPTIONS).not.to.contain('--openssl-legacy-provider')
})
})

context('.exit', () => {
Expand Down
Empty file.
59 changes: 44 additions & 15 deletions npm/webpack-batteries-included-preprocessor/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require('path')
const webpack = require('webpack')
const webpackPreprocessor = require('@cypress/webpack-preprocessor')

const hasTsLoader = (rules) => {
Expand Down Expand Up @@ -131,23 +132,51 @@ const getDefaultWebpackOptions = () => {
loader: require.resolve('coffee-loader'),
}],
},
plugins: [
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
process: 'process/browser',
}),
],
resolve: {
extensions: ['.js', '.json', '.jsx', '.mjs', '.coffee'],
alias: {
'child_process': require.resolve('./empty'),
'cluster': require.resolve('./empty'),
'console': require.resolve('./empty'),
'dgram': require.resolve('./empty'),
'dns': require.resolve('./empty'),
'fs': require.resolve('./empty'),
'http2': require.resolve('./empty'),
'inspector': require.resolve('./empty'),
'module': require.resolve('./empty'),
'net': require.resolve('./empty'),
'perf_hooks': require.resolve('./empty'),
'readline': require.resolve('./empty'),
'repl': require.resolve('./empty'),
'tls': require.resolve('./empty'),
fallback: {
lmiller1990 marked this conversation as resolved.
Show resolved Hide resolved
assert: require.resolve('assert/'),
buffer: require.resolve('buffer/'),
child_process: false,
cluster: false,
console: false,
constants: require.resolve('constants-browserify'),
crypto: require.resolve('crypto-browserify'),
dgram: false,
dns: false,
domain: require.resolve('domain-browser'),
events: require.resolve('events/'),
fs: false,
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
http2: false,
inspector: false,
module: false,
net: false,
os: require.resolve('os-browserify/browser'),
path: require.resolve('path-browserify'),
perf_hooks: false,
punycode: require.resolve('punycode/'),
process: require.resolve('process/browser'),
querystring: require.resolve('querystring-es3'),
readline: false,
repl: false,
stream: require.resolve('stream-browserify'),
string_decoder: require.resolve('string_decoder/'),
sys: require.resolve('util/'),
timers: require.resolve('timers-browserify'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, maybe we do polyfill them all. My previous comment may be irrelevant.

Big breaking change here - who knows if these implementations match whatever webpack 4 was doing.

Tracking down the right polyfill here must have been complex.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, maybe we do polyfill them all. My previous comment may be irrelevant.

Big breaking change here - who knows if these implementations match whatever webpack 4 was doing.

This for sure breaks the webpack-batteries-included-preprocessor . In this case, we polyfill most of them and are fairly explicit about the ones we don't in the config. We also have a few tests in place since just about everything goes through the preprocessor. The tests that we do check for the polyfills are this system test in plugins_spec.js which uses this spec and checks for just about every polyfill in this gist except for the ones starting with _, in particular the readable-stream dependencies. There is also this unit test that pretty much tests the same thing. At least for the built ins we are want to convey we support we should be covered.

Tracking down the right polyfill here must have been complex.

this gist for sure helped to figure out what was going on

tls: false,
tty: require.resolve('tty-browserify'),
url: require.resolve('url/'),
util: require.resolve('util/'),
vm: require.resolve('vm-browserify'),
zlib: require.resolve('browserify-zlib'),
},
plugins: [],
},
Expand Down
24 changes: 22 additions & 2 deletions npm/webpack-batteries-included-preprocessor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,40 @@
"@babel/preset-env": "^7.11.0",
"@babel/preset-react": "^7.10.4",
"@babel/runtime": "^7.11.2",
"assert": "^2.0.0",
"babel-loader": "^8.3.0",
"babel-plugin-add-module-exports": "^1.0.2",
"browserify-zlib": "^0.2.0",
"buffer": "^6.0.3",
"coffee-loader": "^1.0.1",
"coffeescript": "^1.12.7",
"constants-browserify": "^1.0.0",
"crypto-browserify": "^3.12.0",
"domain-browser": "^4.22.0",
"events": "^3.3.0",
"https-browserify": "^1.0.0",
"os-browserify": "^0.3.0",
"path-browserify": "^1.0.1",
"pnp-webpack-plugin": "^1.7.0",
"process": "^0.11.10",
"punycode": "^2.3.0",
"querystring-es3": "^0.2.1",
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
"timers-browserify": "^2.0.12",
"ts-loader": "8.4.0",
"tsconfig-package": "npm:tsconfig@^7.0.0",
"tsconfig-paths-webpack-plugin": "^3.5.2",
"webpack": "^4.46.0"
"tty-browserify": "^0.0.1",
"url": "^0.11.1",
"util": "^0.12.5",
"vm-browserify": "^1.1.2",
"webpack": "^5.88.2"
},
"devDependencies": {
"@cypress/webpack-preprocessor": "0.0.0-development",
"@types/mocha": "^8.0.2",
"@types/webpack": "^4.41.21",
"@types/webpack": "^5.28.1",
"chai": "^4.2.0",
"fs-extra": "^9.1.0",
"mocha": "^8.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ expect(require('net')).to.be.eql({})
expect(require('os')).to.be.an('object').and.have.property('platform')
expect(require('path')).to.be.an('object').and.have.property('join')
expect(require('perf_hooks')).to.eql({})
expect(require('punycode')).to.be.an('object').and.have.property('encode')
const punycode = require('punycode')

expect(typeof punycode).to.equal('object')
expect(punycode).to.have.property('encode')
expect(require('querystring')).to.be.an('object').and.have.property('parse')
expect(require('readline')).to.be.eql({})
expect(require('repl')).to.be.eql({})
Expand Down
17 changes: 14 additions & 3 deletions npm/webpack-preprocessor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,21 @@ const preprocessor: WebpackPreprocessor = (options: PreprocessorOptions = {}): F
// this event is triggered when watching and a file is saved
const onCompile = () => {
debug('compile', filePath)
const nextBundle = utils.createDeferred<string>()
/**
* Webpack 5 fix:
* If the bundle is the initial bundle, do not create the deferred promise
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice job figuring this out 💯

* as we already have one from above. Creating additional deferments on top of
* the first bundle causes reference issues with the first bundle returned, meaning
* the promise that is resolved/rejected is different from the one that is returned, which
* makes the preprocessor permanently hang
*/
if (!bundles[filePath].initial) {
const nextBundle = utils.createDeferred<string>()

bundles[filePath].promise = nextBundle.promise
bundles[filePath].deferreds.push(nextBundle)
}

bundles[filePath].promise = nextBundle.promise
bundles[filePath].deferreds.push(nextBundle)
bundles[filePath].promise.finally(() => {
debug('- compile finished for %s, initial? %s', filePath, bundles[filePath].initial)
// when the bundling is finished, emit 'rerun' to let Cypress
Expand Down
2 changes: 1 addition & 1 deletion npm/webpack-preprocessor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"sinon-chai": "^3.5.0",
"snap-shot-it": "7.9.2",
"ts-node": "^10.9.1",
"webpack": "^4.46.0"
"webpack": "^5.88.2"
},
"peerDependencies": {
"@babel/core": "^7.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"url-parse": "1.5.9",
"vanilla-text-mask": "5.1.1",
"vite": "4.3.2",
"webpack": "^4.46.0",
"webpack": "^5.88.2",
"zone.js": "0.9.0"
},
"files": [
Expand Down
9 changes: 8 additions & 1 deletion packages/driver/src/cy/commands/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,14 @@ export default (Commands, Cypress, cy, state) => {
}

// Add the filename as a symbol, in case we need it later (such as when storing an alias)
state('current').set('fileName', basename(filePath))
try {
lmiller1990 marked this conversation as resolved.
Show resolved Hide resolved
state('current').set('fileName', basename(filePath))
} catch (e) {
// as of Webpack 5, the "path-browserify" polyfill requires the "path"
// argument in "basename" to be a string. Otherwise, the function throws.
// when this happens, we want to set the filename to "undefined" as fallback behavior.
state('current').set('fileName', 'undefined')
}

consoleProps['File Path'] = filePath
consoleProps['Contents'] = contents
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"sinon-chai": "3.3.0",
"ts-loader": "8.4.0",
"webextension-polyfill": "0.4.0",
"webpack": "4.44.2"
"webpack": "^5.88.2"
},
"files": [
"app",
Expand Down
Loading