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

feat: webpack 5 support #8929

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion npm/react/examples/webpack-file/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"test": "node ../../../../scripts/cypress run"
},
"devDependencies": {
"@cypress/react": "file:../../dist"
"@cypress/react": "file:../../dist",
"webpack": "5.1.3"
}
}
442 changes: 436 additions & 6 deletions npm/react/examples/webpack-file/yarn.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions npm/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
"svg-url-loader": "3.0.3",
"typescript": "4.0.3",
"victory": "34.3.6",
"webpack": "4.44.1",
"webpack-cli": "3.3.9"
"webpack": "5.1.3",
"webpack-cli": "4.1.0"
},
"peerDependencies": {
"@babel/core": "^=7.x",
Expand Down
24 changes: 7 additions & 17 deletions npm/webpack-preprocessor/__snapshots__/compilation.spec.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
exports['webpack preprocessor - e2e correctly preprocesses the file 1'] = `
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){e.exports=n(1)},function(e,t){it("is a test",(function(){expect(1).to.equal(1),expect(2).to.equal(2),expect(Math.min.apply(Math,[3,4])).to.equal(3)}))}]);
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAiLCJ3ZWJwYWNrOi8vLy4vdGVzdC9fdGVzdC1vdXRwdXQvZXhhbXBsZV9zcGVjLmpzIl0sIm5hbWVzIjpbImluc3RhbGxlZE1vZHVsZXMiLCJfX3dlYnBhY2tfcmVxdWlyZV9fIiwibW9kdWxlSWQiLCJleHBvcnRzIiwibW9kdWxlIiwiaSIsImwiLCJtb2R1bGVzIiwiY2FsbCIsIm0iLCJjIiwiZCIsIm5hbWUiLCJnZXR0ZXIiLCJvIiwiT2JqZWN0IiwiZGVmaW5lUHJvcGVydHkiLCJlbnVtZXJhYmxlIiwiZ2V0IiwiciIsIlN5bWJvbCIsInRvU3RyaW5nVGFnIiwidmFsdWUiLCJ0IiwibW9kZSIsIl9fZXNNb2R1bGUiLCJucyIsImNyZWF0ZSIsImtleSIsImJpbmQiLCJuIiwib2JqZWN0IiwicHJvcGVydHkiLCJwcm90b3R5cGUiLCJoYXNPd25Qcm9wZXJ0eSIsInAiLCJzIiwiaXQiLCJleHBlY3QiLCJ0byIsImVxdWFsIiwiTWF0aCIsIm1pbiJdLCJtYXBwaW5ncyI6ImFBQ0UsSUFBSUEsRUFBbUIsR0FHdkIsU0FBU0MsRUFBb0JDLEdBR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EnLCBnZXR0ZXIpO1xuIFx0XHRyZXR1cm4gZ2V0dGVyO1xuIFx0fTtcblxuIFx0Ly8gT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsXG4gXHRfX3dlYnBhY2tfcmVxdWlyZV9fLm8gPSBmdW5jdGlvbihvYmplY3QsIHByb3BlcnR5KSB7IHJldHVybiBPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwob2JqZWN0LCBwcm9wZXJ0eSk7IH07XG5cbiBcdC8vIF9fd2VicGFja19wdWJsaWNfcGF0aF9fXG4gXHRfX3dlYnBhY2tfcmVxdWlyZV9fLnAgPSBcIlwiO1xuXG5cbiBcdC8vIExvYWQgZW50cnkgbW9kdWxlIGFuZCByZXR1cm4gZXhwb3J0c1xuIFx0cmV0dXJuIF9fd2VicGFja19yZXF1aXJlX18oX193ZWJwYWNrX3JlcXVpcmVfXy5zID0gMCk7XG4iLCJpdCgnaXMgYSB0ZXN0JywgKCkgPT4ge1xuICBjb25zdCBbYSwgYl0gPSBbMSwgMl1cblxuICBleHBlY3QoYSkudG8uZXF1YWwoMSlcbiAgZXhwZWN0KGIpLnRvLmVxdWFsKDIpXG4gIGV4cGVjdChNYXRoLm1pbiguLi5bMywgNF0pKS50by5lcXVhbCgzKVxufSlcbiJdLCJzb3VyY2VSb290IjoiIn0=
it("is a test",(function(){expect(1).to.equal(1),expect(2).to.equal(2),expect(Math.min.apply(Math,[3,4])).to.equal(3)}));
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly9AY3lwcmVzcy93ZWJwYWNrLXByZXByb2Nlc3Nvci8uL3Rlc3QvX3Rlc3Qtb3V0cHV0L2V4YW1wbGVfc3BlYy5qcyJdLCJuYW1lcyI6WyJpdCIsImV4cGVjdCIsInRvIiwiZXF1YWwiLCJNYXRoIiwibWluIl0sIm1hcHBpbmdzIjoiQUFBQUEsR0FBRyxhQUFhLFdBR2RDLE9BRmdCLEdBRU5DLEdBQUdDLE1BQU0sR0FDbkJGLE9BSG1CLEdBR1RDLEdBQUdDLE1BQU0sR0FDbkJGLE9BQU9HLEtBQUtDLElBQUwsTUFBQUQsS0FBWSxDQUFDLEVBQUcsS0FBS0YsR0FBR0MsTUFBTSIsImZpbGUiOiJleGFtcGxlX3NwZWNfb3V0cHV0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiaXQoJ2lzIGEgdGVzdCcsICgpID0+IHtcbiAgY29uc3QgW2EsIGJdID0gWzEsIDJdXG5cbiAgZXhwZWN0KGEpLnRvLmVxdWFsKDEpXG4gIGV4cGVjdChiKS50by5lcXVhbCgyKVxuICBleHBlY3QoTWF0aC5taW4oLi4uWzMsIDRdKSkudG8uZXF1YWwoMylcbn0pXG4iXSwic291cmNlUm9vdCI6IiJ9
`

exports['webpack preprocessor - e2e has less verbose "Module not found" error 1'] = `
Webpack CompLooked for and couldn't find the file at the following paths:resolve './does/not-exist' in '<path>/_test-output'
`

exports['webpack preprocessor - e2e has less verbose syntax error 1'] = `
Webpack Compilation Error
.<path>/_test-output/syntax_error_spec.js
Module build failed (from /[root]/node_modules/babel-loader/lib/index.js):
Module build failed (from ../../node_modules/babel-loader/lib/index.js):
SyntaxError: <path>/_test-output/syntax_error_spec.js: Unexpected token (1:18)

> 1 | describe('fail', ->)
  |  ^
  2 | 
`

exports['webpack preprocessor - e2e has less verbose "Module not found" error 1'] = `
Webpack Compilation Error
.<path>/_test-output/imports_nonexistent_file_spec.js
Module not found: Error: Can't resolve './does/not-exist' in '<path>/_test-output'
Looked for and couldn't find the file at the following paths:
[<path>/_test-output/does/not-exist]
[<path>/_test-output/does/not-exist.wasm]
[<path>/_test-output/does/not-exist.mjs]
[<path>/_test-output/does/not-exist.js]
[<path>/_test-output/does/not-exist.json]
@ .<path>/_test-output/imports_nonexistent_file_spec.js 1:0-26
`
17 changes: 6 additions & 11 deletions npm/webpack-preprocessor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,7 @@ const preprocessor: WebpackPreprocessor = (options: PreprocessorOptions = {}): F
if (file.shouldWatch) {
debug('watching')

if (compiler.hooks) {
// TODO compile.tap takes "string | Tap"
// so seems we just need to pass plugin.name
// @ts-ignore
compiler.hooks.compile.tap(plugin, onCompile)
} else {
compiler.plugin('compile', onCompile)
}
compiler.hooks.compile.tap(plugin.name, onCompile)
}

const bundler = file.shouldWatch ? compiler.watch(watchOptions, handle) : compiler.run(handle)
Expand All @@ -351,7 +344,7 @@ const preprocessor: WebpackPreprocessor = (options: PreprocessorOptions = {}): F

if (file.shouldWatch) {
// in this case the bundler is webpack.Compiler.Watching
(bundler as webpack.Compiler.Watching).close(cb)
(bundler as webpack.Compiler['watching']).close(cb)
}
})

Expand Down Expand Up @@ -379,8 +372,10 @@ preprocessor.__reset = () => {
bundles = {}
}

function cleanseError (err: string) {
return err.replace(/\n\s*at.*/g, '').replace(/From previous event:\n?/g, '')
function cleanseError (err: string | Error) {
const errorMessage = typeof err === 'string' ? err : err.message

return errorMessage.replace(/\n\s*at.*/g, '').replace(/From previous event:\n?/g, '')
}

export = preprocessor
6 changes: 3 additions & 3 deletions npm/webpack-preprocessor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@
"snap-shot-it": "7.9.2",
"start-server-and-test": "1.10.11",
"ts-node": "8.10.1",
"typescript": "3.8.3",
"webpack": "^4.18.1"
"typescript": "4.0.3",
"webpack": "^5.1.3"
},
"peerDependencies": {
"@babel/core": "^7.0.1",
"@babel/preset-env": "^7.0.0",
"babel-loader": "^8.0.2",
"webpack": "^4.18.1"
"webpack": "^4.x || ^5.x"
},
"files": [
"dist"
Expand Down
12 changes: 8 additions & 4 deletions npm/webpack-preprocessor/test/unit/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ describe('webpack preprocessor', function () {
this.compilerApi = {
run: sinon.stub(),
watch: sinon.stub().returns(this.watchApi),
plugin: sinon.stub(),
hooks: {
compile: {
tap: sinon.stub(),
},
},
}

webpack.returns(this.compilerApi)
Expand Down Expand Up @@ -251,13 +255,13 @@ describe('webpack preprocessor', function () {
it('emits "rerun" when shouldWatch is true after there is an update', function () {
this.file.shouldWatch = true
this.compilerApi.watch.yields(null, this.statsApi)
this.compilerApi.plugin.withArgs('compile').yields()
this.compilerApi.hooks.compile.tap.yields()

return this.run()
.then(() => {
expect(this.file.emit).not.to.be.calledWith('rerun')

this.compilerApi.plugin.withArgs('compile').yield()
this.compilerApi.hooks.compile.tap.yield()
this.compilerApi.watch.yield(null, this.statsApi)

return Promise.delay(10) // give assertion time till next tick
Expand All @@ -269,7 +273,7 @@ describe('webpack preprocessor', function () {

it('does not emit "rerun" when shouldWatch is false', function () {
this.file.shouldWatch = false
this.compilerApi.plugin.withArgs('compile').yields()
this.compilerApi.hooks.compile.tap.yields()

return this.run().then(() => {
expect(this.file.emit).not.to.be.calledWith('rerun')
Expand Down
Loading