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!: import defineConfig from kirbyup/config (#19) #21

Merged
merged 3 commits into from
Aug 10, 2022

Conversation

johannschopplich
Copy link
Owner

Fix #19.

@jonaskuske What do you think? Seems like the most straight forward solution.

@johannschopplich johannschopplich changed the title fix: slow defineConfig behaviour (#19) fix!: slow defineConfig behaviour (#19) Aug 9, 2022
@johannschopplich johannschopplich changed the title fix!: slow defineConfig behaviour (#19) fix!: import defineConfig from kirbyup/config (#19) Aug 9, 2022
@jonaskuske
Copy link
Collaborator

Would've said it looks good, but now that I've tested it, it doesn't appear to work :(

TS / IntelliSense doesn't pick up on the export, there's no auto-complete and auto-import for defineConfig and if you import it manually it still doesn't offer type completion. 🤔

@johannschopplich
Copy link
Owner Author

Node.js v12+ extends package entry points features like subpath exports or conditional exports, but TypeScript supports them only with the NodeNext module resolution:

{
  "compilerOptions": {
    "moduleResolution": "NodeNext"
  }
}

Reference: microsoft/TypeScript#33079

Because many developers, including myself, are using "moduleResolution": "Node" solely, we add a workaround utilizing typesVersions.

@jonaskuske
Copy link
Collaborator

jonaskuske commented Aug 10, 2022

Found the culprit!

The downstream project needs to add a jsconfig.json / tsconfig.json with

{
  "compilerOptions": {
    "moduleResolution": "Node16"
  }
}

so TypeScript/IntelliSense correctly resolves package.json#exports.

With that, suggestions work if you try to import the function and the typings work too.

Auto-import still doesn't work, so you can't just type defineC, hit Tab and VSCode completes the function name and adds the import to the top automatically, but that's just a minor issue.

Edit: heh, a couple minutes too late :D

@jonaskuske
Copy link
Collaborator

Update: the workaround is working!

Still not for auto-imports, but that might just be a TS/IntelliSense bug or limitation?

@johannschopplich
Copy link
Owner Author

johannschopplich commented Aug 10, 2022

Limitation of the types version workaround. Still, everything we can do upstream inside the package.

@johannschopplich johannschopplich merged commit f2be3f0 into main Aug 10, 2022
@johannschopplich johannschopplich deleted the fix/kirbyup-config-loading branch August 10, 2022 12:35
@jonaskuske
Copy link
Collaborator

Limitation of the types version workaround

Are you sure? I see the same behavior with "moduleResolution": "Node16" and without the typesVersion workaround, so maybe it's a broader bug with type indexing/acquisition in ESM modules?

@johannschopplich
Copy link
Owner Author

Good question, I don't know. 👀

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.

Extremely slow starts if kirbyup.config exists
2 participants