composition-api
composition-api copied to clipboard
Extend package.json to be compatible with moduleResolution: bundler
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch @nuxtjs/[email protected] for the project I'm working on.
The patch is related to the newly introduced default bundler module resolutionn for Nuxt 3 and respectively nuxt-module-builder. As we have to support both Nuxt 3 and Nuxt 2 with some of our internal Nuxt modules, we have gotten some build errors during our recent [email protected] update.
src/composables/someFile.ts(1,26): error TS7016: Could not find a declaration file for module '@nuxtjs/composition-api'. '/(...)/custom-nuxt-module/node_modules/@nuxtjs/composition-api/dist/runtime/index.mjs' implicitly has an 'any' type. There are types at '/(...)/custom-nuxt-module/node_modules/@nuxtjs/composition-api/dist/runtime/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@nuxtjs/composition-api' library may need to update its package.json or typings.
Please let me know if it helps to create a quick pull request with this change or if we need to extend the type definitions to cover more cases.
Here is the diff that solved our problem:
diff --git a/node_modules/@nuxtjs/composition-api/package.json b/node_modules/@nuxtjs/composition-api/package.json
index cb246ed..6b9b433 100644
--- a/node_modules/@nuxtjs/composition-api/package.json
+++ b/node_modules/@nuxtjs/composition-api/package.json
@@ -19,7 +19,16 @@
},
"sideEffects": true,
"exports": {
- ".": "./dist/runtime/index.mjs",
+ ".": {
+ "import": {
+ "types": "./dist/runtime/index.d.ts",
+ "default": "./dist/runtime/index.mjs"
+ },
+ "require": {
+ "types": "./dist/runtime/index.d.ts",
+ "default": "./dist/runtime/index.js"
+ }
+ },
"./module": "./dist/module/index.mjs",
"./package.json": "./package.json",
"./dist/babel-plugin": "./dist/babel-plugin/index.js",
This issue body was partially generated by patch-package.