Skip to content

Commit

Permalink
Merge pull request #19 from th3fallen/update-loader
Browse files Browse the repository at this point in the history
upgrade cypress to version 13
  • Loading branch information
xfsnowind authored Dec 22, 2023
2 parents a925f6e + 10545dc commit 5165ecb
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 30 deletions.
14 changes: 12 additions & 2 deletions dist/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ const makeImport = (file, filename, chunkName, projectRoot) => {
// If we want to rename the chunks, we can use this
const magicComments = chunkName ? `/* rspackChunkName: "${chunkName}" */` : '';
return `"${filename}": {
shouldLoad: () => decodeURI(document.location.pathname).includes("${file.absolute}"),
shouldLoad: () => {
const newLoad = new URLSearchParams(document.location.search).get("specPath") === "${file.absolute}";
const oldLoad = decodeURI(document.location.pathname).includes("${file.absolute}");
return newLoad | oldLoad;
},
load: () => import(${magicComments} "${file.absolute}"),
absolute: "${file.absolute.split(path.sep).join(path.posix.sep)}",
relative: "${file.relative.split(path.sep).join(path.posix.sep)}",
Expand All @@ -30,7 +34,13 @@ const makeImport = (file, filename, chunkName, projectRoot) => {
* @returns {Record<string, ReturnType<makeImport>}
* {
* "App.spec.js": {
* shouldLoad: () => document.location.pathname.includes('cypress/component/App.spec.js'),
* shouldLoad: () => {
const newLoad = new URLSearchParams(document.location.search).get("specPath") === "${
file.absolute
}";
const oldLoad = decodeURI(document.location.pathname).includes("${file.absolute}");
return newLoad | oldLoad;
},
* load: () => {
* return import("/Users/projects/my-app/cypress/component/App.spec.js" \/* rspackChunkName: "spec-0" *\/)
* },
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@typescript-eslint/parser": "^6.11.0",
"babel-jest": "^29.7.0",
"cross-env": "^7.0.3",
"cypress": "^12.13.0",
"cypress": "^13.6.1",
"debug": "^4.3.4",
"dedent": "^0.7.0",
"eslint": "^8.54.0",
Expand Down
74 changes: 49 additions & 25 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ const makeImport = (
const magicComments = chunkName ? `/* rspackChunkName: "${chunkName}" */` : ''

return `"${filename}": {
shouldLoad: () => decodeURI(document.location.pathname).includes("${file.absolute}"),
shouldLoad: () => {
const newLoad = new URLSearchParams(document.location.search).get("specPath") === "${
file.absolute
}";
const oldLoad = decodeURI(document.location.pathname).includes("${file.absolute}");
return newLoad | oldLoad;
},
load: () => import(${magicComments} "${file.absolute}"),
absolute: "${file.absolute.split(path.sep).join(path.posix.sep)}",
relative: "${file.relative.split(path.sep).join(path.posix.sep)}",
Expand All @@ -39,7 +45,13 @@ const makeImport = (
* @returns {Record<string, ReturnType<makeImport>}
* {
* "App.spec.js": {
* shouldLoad: () => document.location.pathname.includes('cypress/component/App.spec.js'),
* shouldLoad: () => {
const newLoad = new URLSearchParams(document.location.search).get("specPath") === "${
file.absolute
}";
const oldLoad = decodeURI(document.location.pathname).includes("${file.absolute}");
return newLoad | oldLoad;
},
* load: () => {
* return import("/Users/projects/my-app/cypress/component/App.spec.js" \/* rspackChunkName: "spec-0" *\/)
* },
Expand Down

0 comments on commit 5165ecb

Please sign in to comment.