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(nuxt): provide node16-style type exports #18431

Merged
merged 14 commits into from Mar 11, 2023
Merged

fix(nuxt): provide node16-style type exports #18431

merged 14 commits into from Mar 11, 2023

Conversation

danielroe
Copy link
Member

@danielroe danielroe commented Jan 21, 2023

πŸ”— Linked issue

#19606

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This PR makes some updates to Nuxt internals to improve support for Node16-style module resolution.

πŸ‘‰ Current status

nuxt v3.2.3
"nuxt""nuxt/config""nuxt/schema""nuxt/app""nuxt/package.json"
node10 βœ… βœ… βœ… βœ… βœ… (JSON)
node16 (from CJS) ❌ No types
⚠️ ESM (dynamic import only)
πŸ‘Ί Masquerading as ESM
⚠️ ESM (dynamic import only)
⚠️ ESM (dynamic import only)❌ No types
⚠️ ESM (dynamic import only)
βœ… (JSON)
node16 (from ESM) ❌ No typesβœ… (ESM)βœ… (ESM)❌ No typesβœ… (JSON)
bundler ❌ No typesβœ… βœ… ❌ No typesβœ… (JSON)
nuxt (edge)
"nuxt3""nuxt3/config""nuxt3/schema""nuxt3/kit""nuxt3/app""nuxt3/package.json"
node10 βœ… βœ… βœ… βœ… βœ… βœ… (JSON)
node16 (from CJS) ❌ No types
⚠️ ESM (dynamic import only)
πŸ‘Ί Masquerading as ESM
⚠️ ESM (dynamic import only)
⚠️ ESM (dynamic import only)⚠️ ESM (dynamic import only)❌ No types
⚠️ ESM (dynamic import only)
βœ… (JSON)
node16 (from ESM) ❌ No typesβœ… (ESM)βœ… (ESM)βœ… (ESM)❌ No typesβœ… (JSON)
bundler ❌ No typesβœ… βœ… βœ… ❌ No typesβœ… (JSON)
after this pr
"nuxt""nuxt/config""nuxt/schema""nuxt/kit""nuxt/app""nuxt/package.json"
node10 βœ… βœ… βœ… βœ… βœ… βœ… (JSON)
node16 (from CJS) ⚠️ ESM (dynamic import only)πŸ‘Ί Masquerading as ESM
⚠️ ESM (dynamic import only)
⚠️ ESM (dynamic import only)⚠️ ESM (dynamic import only)⚠️ ESM (dynamic import only)βœ… (JSON)
node16 (from ESM) βœ… (ESM)βœ… (ESM)βœ… (ESM)βœ… (ESM)βœ… (ESM)βœ… (JSON)
bundler βœ… βœ… βœ… βœ… βœ… βœ… (JSON)

See https://arethetypeswrong.github.io.

the remaining blockers for full support for Node16 format can be tracked in #19606.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codesandbox
Copy link

codesandbox bot commented Jan 21, 2023

CodeSandbox logoCodeSandbox logoΒ  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@dargmuesli
Copy link
Member

minor notice: the issue mentioned is not linked properly because of a typo in "resolves" 🀫

@danielroe danielroe requested a review from pi0 March 8, 2023 10:09
@danielroe danielroe marked this pull request as ready for review March 8, 2023 10:28
Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

Nice work on this πŸ”₯

packages/kit/package.json Outdated Show resolved Hide resolved
@danielroe danielroe mentioned this pull request Mar 8, 2023
packages/kit/package.json Outdated Show resolved Hide resolved
@danielroe
Copy link
Member Author

Okay, so that's why I kept it in: https://github.com/nuxt/nuxt/actions/runs/4363710497/jobs/7630133013

@pi0
Copy link
Member

pi0 commented Mar 8, 2023

Strange... It is vitest or jiti? (jiti fallsback to import condition and we have enabled this behavior)

@danielroe
Copy link
Member Author

danielroe commented Mar 8, 2023

I think it's neither - I think it's the call to _require.resolve in our deprecated cjs utils in kit:

export function resolveModule (id: string, paths?: string | string[]) {
return normalize(_require.resolve(id, { paths: getModulePaths(paths) }))
}

(Though this might then be jiti.)

Replicable with built monorepo:

./packages/nuxi/bin/nuxi.mjs prepare test/fixtures/basic

@danielroe danielroe merged commit b19b35f into main Mar 11, 2023
@danielroe danielroe deleted the chore/node16 branch March 11, 2023 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants