Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: move the module to be esm #221

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

Merged
yanick merged 19 commits into testing-library:main from yanick:without-babel
Jun 22, 2023
Merged

Conversation

@yanick
Copy link
Collaborator

@yanick yanick commented Jun 7, 2023
edited
Loading

To do that I've also switched jest for vitest

NOTE I'm soon going to be potentially without Internet connection. I don't want to merge this and just walk away, so I'll need some 👍 and backup peeps on this one.

Might fix #220

BREAKING CHANGE: moves the package from cjs to esm.

benmccann reacted with hooray emoji benmccann reacted with rocket emoji
@yanick yanick changed the title (削除) move the module to be esm (削除ここまで) (追記) breaking: move the module to be esm (追記ここまで) Jun 7, 2023
@yanick yanick changed the title (削除) breaking: move the module to be esm (削除ここまで) (追記) feat: move the module to be esm (追記ここまで) Jun 7, 2023
yanick added 6 commits June 7, 2023 10:06
To do that I've also switched jest for vitest
**NOTE** I'm soon going to be potentially without Internet connection.
I don't want to merge this and just walk away, so I'll need some
:+1: and backup peeps on this one.
Copy link
Collaborator Author

yanick commented Jun 7, 2023

@cesarnml can you try this branch for #220 and see if it solves the problem?

cesarnml reacted with thumbs up emoji

Copy link
Collaborator Author

yanick commented Jun 7, 2023

fwiw, it works for me (once I installed @testing-library/dom)

Copy link

cesarnml commented Jun 7, 2023
edited
Loading

@cesarnml can you try this branch for #220 and see if it solves the problem?

I attempted to apply the patched branch "@testing-library/svelte": "github:yanick/svelte-testing-library", and installed @testing-library/dom, but now I see a new error:

 FAIL src/routes/page.spec.ts [ src/routes/page.spec.ts ]
Error: Failed to resolve entry for package "@testing-library/svelte". The package may have incorrect main/module/exports specified in its package.json.
 ❯ packageEntryFailure node_modules/.pnpm/vite@4.3.9_@types+node@20.2.5/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:23382:11
 ❯ resolvePackageEntry node_modules/.pnpm/vite@4.3.9_@types+node@20.2.5/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:23379:5
 ❯ tryNodeResolve node_modules/.pnpm/vite@4.3.9_@types+node@20.2.5/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:23113:20
 ❯ Context.resolveId node_modules/.pnpm/vite@4.3.9_@types+node@20.2.5/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:22874:28
 ❯ Object.resolveId node_modules/.pnpm/vite@4.3.9_@types+node@20.2.5/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:42847:46
 ❯ TransformContext.resolve node_modules/.pnpm/vite@4.3.9_@types+node@20.2.5/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:42575:23
 ❯ normalizeUrl node_modules/.pnpm/vite@4.3.9_@types+node@20.2.5/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:40500:34
 ❯ async file:/Users/cesar/code/svelte4-testing-example/node_modules/.pnpm/vite@4.3.9_@types+node@20.2.5/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:40651:47
 ❯ TransformContext.transform node_modules/.pnpm/vite@4.3.9_@types+node@20.2.5/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:40577:13

Full disclosure.

Module resolution errors are not my cup of tea, so it's perfectly possible that I don't know how to apply the fix properly. Open to suggestions here.

Repo with patched branch:
https://github.com/cesarnml/svelte4-testing-example/blob/759b0999bb8f840f97864bf930707eb69e30c442/package.json#L20

Steps I took from minimal example repo to patch repo:
pnpm i -D yanick/svelte-testing-library
pnpm i -D @testing-library/dom
pnpm test:unit

Let me know if I goofed on applying the fix @yanick

Copy link

cesarnml commented Jun 7, 2023
edited
Loading

@yanick

Okay. I just realized I need to target without-babel branch above.

The fix works for me too!

Thank you for the quick turn around time. Only other suggestion I have is to perhaps update the peer dependency designation wrt svelte:

 WARN Issues with peer dependencies found
.
└─┬ @testing-library/svelte 0.0.0-semantically-released
 └── ✕ unmet peer svelte@3.x: found 4.0.0-next.0

working and patched example:
https://github.com/cesarnml/svelte4-testing-example/blob/1f7ab0768510495fcb5c317b5ae769902bf777c4/package.json#L41

Update:
Patch also works on my production svelte-kit app repo I'm working on. 🎉 🙏 . Ship it 😄
https://github.com/cesarnml/waka-shortcut-time-stats

Copy link
Collaborator Author

yanick commented Jun 7, 2023

just realized I need to target without-babel branch above.

Heh. You fixed it as I was finding the same thing. ^.^

The fix works for me too! Thank you for the quick turn around time. Only other suggestion I have is to perhaps update the peer dependency designation wrt svelte:

Yeah, we should probably do that once svelte 4.0.0 gets out of alpha.

Update: Patch also works on my production svelte-kit app repo I'm working on. tada pray . Ship it smile https://github.com/cesarnml/waka-shortcut-time-stats

Woo! Now, I'm about to be offline for a few days, so I won't do the mistake of merging and going dark. :turn to the whole room: Do we have another maintainer who can check this PR and, if we merge, keep eyes on the status of things for the next few days?

Copy link

cesarnml commented Jun 7, 2023
edited
Loading

Update!: Spoke too soon. Found this error on my production branch above.

Error: No "exports" main defined in /Users/cesar/code/waka-shortcut-time-stats/node_modules/.pnpm/@testing-library+svelte@3.2.2_svelte@4.0.0-next.0/node_modules/svelte/package.json
 ❯ Object.<anonymous> node_modules/.pnpm/@testing-library+svelte@3.2.2_svelte@4.0.0-next.0/node_modules/@testing-library/svelte/dist/pure.js:28:15
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: {
 "code": "ERR_PACKAGE_PATH_NOT_EXPORTED",
}

Copy link
Collaborator Author

yanick commented Jun 7, 2023

Could be from the pure.js in the root directory. I tweaked it, try again?

cesarnml reacted with thumbs up emoji

Copy link

cesarnml commented Jun 7, 2023

Could be from the pure.js in the root directory. I tweaked it, try again?

 Test Files 31 passed (31)
 Tests 60 passed (60)
 Start at 10:20:19
 Duration 12.71s (transform 1.39s, setup 12.87s, collect 11.49s, tests 1.44s, environment 10.89s, prepare 2.36s)
 % Coverage report from c8

Success. No issues now.

Copy link
Collaborator Author

yanick commented Jun 7, 2023

Success. No issues now.

I AM A GOD! \o/

cesarnml and erikdunning reacted with laugh emoji cesarnml and erikdunning reacted with hooray emoji

Copy link

cesarnml commented Jun 7, 2023
edited
Loading

Success. No issues now.

I AM A GOD! \o/

🐐 🤣

yanick and erikdunning reacted with laugh emoji

package.json Outdated
"eslint-plugin-svelte3": "^4.0.0",
"husky": "^7.0.1",
"jest": "^27.0.0",
"jest": "^29.5.0",
Copy link
Contributor

@benmccann benmccann Jun 14, 2023
edited
Loading

Choose a reason for hiding this comment

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

Do we need jest and Vitest installed? (also jest-environment-jsdom and svelte-jester)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops. Leftover. Removing...

.eslintrc.cjs Outdated
browser: true,
es6: true,
jest: true
jest: true,
Copy link
Contributor

@benmccann benmccann Jun 14, 2023

Choose a reason for hiding this comment

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

Do we still need this line if we're using Vitest?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm... Maybe for the globals. Let's see ! :goes to console:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Switched to the vitest env

"e2e"
],
"files": [
"dist",
Copy link

@dummdidumm dummdidumm Jun 14, 2023

Choose a reason for hiding this comment

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

Does probably also need src/pure.js and src/index.js now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True!

package.json Outdated
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-svelte3": "^4.0.0",
Copy link
Contributor

@benmccann benmccann Jun 14, 2023

Choose a reason for hiding this comment

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

this is the older original package. there's now an eslint-plugin-svelte that you might want to migrate to

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Migrated!

package.json Outdated
Comment on lines 33 to 34
"src/pure.js",
"src/index.js",
Copy link
Contributor

@benmccann benmccann Jun 17, 2023

Choose a reason for hiding this comment

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

I would make this src/ so that things don't unexpectedly break if you add another file

Suggested change
"src/pure.js",
"src/index.js",
"src/",

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Point. Done!

package.json Outdated
"src/pure.js",
"src/index.js",
"dont-cleanup-after-each.js",
"pure.js",
Copy link
Contributor

@benmccann benmccann Jun 17, 2023

Choose a reason for hiding this comment

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

I don't think you need this since it's in src now. not sure what dont-cleanup-after-each is and whether you need that one or not

Suggested change
"pure.js",

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed both. dont-cleanup-after-each seems to be a helper package for setting the env variable that is not used anywhere anyway.

package.json Outdated
"eslint": "^8.42.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-node": "^11.1.0",
Copy link
Contributor

@benmccann benmccann Jun 17, 2023

Choose a reason for hiding this comment

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

I think this one is no longer maintained so folks use eslint-plugin-n now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good to know! Done!

yanick and others added 3 commits June 19, 2023 14:20
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Copy link
Contributor

@benmccann benmccann left a comment

Choose a reason for hiding this comment

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

I would still recommend putting exports in the package.json. lgtm besides that

yanick reacted with thumbs up emoji
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Copy link
Contributor

Svelte 4 will be released imminently. It could be good to merge this in order to avoid any bug reports

Copy link
Collaborator Author

yanick commented Jun 21, 2023 via email

I can merge, but I'm away from any keyboards for the next 2 weeks, which means that if the branch introduce any problem, things will be broken for a while. Is there any other maintainer that can jump in if this happens?
...
On 2023年6月21日, at 5:29 PM, Ben McCann wrote: Svelte 4 will be released imminently. It could be good to merge this in order to avoid any bug reports — Reply to this email directly, view it on GitHub <#221 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAAE34TDKW4JUJNCX7LY5A3XMMHMFANCNFSM6AAAAAAY5F7G2Y>. You are receiving this because you were mentioned.Message ID: ***@***.***>

Copy link
Contributor

I don't have any historical familiarity with this library, but can try to take a look if any issues pop up

Copy link
Collaborator Author

yanick commented Jun 22, 2023

I don't have any historical familiarity with this library, but can try to take a look if any issues pop up

Okie. There goes nothing!

@yanick yanick merged commit fe21493 into testing-library:main Jun 22, 2023
Copy link

🎉 This PR is included in version 4.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

2 more reviewers

@dummdidumm dummdidumm dummdidumm left review comments

@benmccann benmccann benmccann approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Module distribution incompatible with upcoming svelte4 release

AltStyle によって変換されたページ (->オリジナル) /