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

fix: overwrite nodenext option when transpiling #11092

Merged
merged 4 commits into from
Nov 22, 2023
Merged

Conversation

dummdidumm
Copy link
Member

transpileModule treats NodeNext as CommonJS because it doesn't read the package.json. Therefore we need to override it. Also see microsoft/TypeScript#53022 (the filename workaround doesn't work). Fixes #11086

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

transpileModule treats NodeNext as CommonJS because it doesn't read the package.json. Therefore we need to override it. Also see microsoft/TypeScript#53022 (the filename workaround doesn't work).
Fixes #11086
Copy link

changeset-bot bot commented Nov 21, 2023

🦋 Changeset detected

Latest commit: 9162fdd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/package Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@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.

thank you! I was just coming to a similar conclusion, but you beat me to it 😄

the other thing I've been wondering is if we should switch nodenext for node16. it seems a bit brittle to use nodenext as its meaning could change at any time and so i'm not sure if it's what we should encourage

@dummdidumm
Copy link
Member Author

I think it's better to use nodenext because it means we're always up to date with regards to how module resolution is done.

@benmccann
Copy link
Member

Actually, on giving this more thought, I think there's another issue with the way we're testing this. We seem not to be using the tsconfig.json created by create-svelte for testing and instead providing our own. If we used the created one then we would have caught the issue.

It feels to me like we should delete the typescript-esnext test. It's a pretty weird one. It doesn't test create-svelte at all. It tests creating a project with create-svelte and then that the user changed settings in a way that didn't break things. But why are we testing what the user is doing? They could make any set of changes.

And then we should update the typescript-nodenext test to not provide a tsconfig.json but use the one created by create-svelte. Because what happens if we later change the value to something other than esnext or nodenext?

@dummdidumm
Copy link
Member Author

We should keep the tests, because it ensures that tsconfig settings we had a various points in time all work properly. The idea of having a "use create-svelte's current tsconfig" test is good.

@benmccann
Copy link
Member

Oh, yeah, that makes sense. I didn't realize this was a package test and was thinking it was a create-svelte test 😆

@benmccann benmccann merged commit 35e6e75 into master Nov 22, 2023
14 checks passed
@benmccann benmccann deleted the fix-packaging branch November 22, 2023 17:48
@github-actions github-actions bot mentioned this pull request Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

create-svelte generates a CJS output
3 participants