nuxt-modules / apollo

Nuxt.js module to use Vue-Apollo. The Apollo integration for GraphQL.
https://apollo.nuxtjs.org
MIT License
956 stars 198 forks source link

build with nuxt3 not find tslib #516

Open NaCoLiu opened 1 year ago

NaCoLiu commented 1 year ago

Environment

Nuxi 3.5.3                                                                                                                    7:32:45 PM
                                                                                                                              7:32:45 PM
RootDir: /Users/naco/Documents/retain                                                                                         7:32:45 PM
Nuxt project info: (copied to clipboard)                                                                                      7:32:45 PM

------------------------------
- Operating System: Darwin
- Node Version:     v18.16.0
- Nuxt Version:     3.5.3
- Nitro Version:    2.4.1
- Package Manager:  pnpm@8.6.3
- Builder:          vite
- User Config:      app, devtools, srcDir, modules, imports, pinia, alias, apollo
- Runtime Modules:  @nuxtjs/apollo@5.0.0-alpha.6, @pinia/nuxt@0.4.11
- Build Modules:    -
------------------------------

šŸ‘‰ Report an issue: https://github.com/nuxt/nuxt/issues/new                                                                   7:32:45 PM

šŸ‘‰ Suggest an improvement: https://github.com/nuxt/nuxt/discussions/new

šŸ‘‰ Read documentation: https://nuxt.com

Describe the bug

naco@NaCo retain % node .output/server/index.mjs    
Listening http://[::]:3000
[nuxt] [request error] [unhandled] [500] Cannot find module '/Users/naco/Documents/retain/.output/server/node_modules/tslib/modules/index.js' imported from /Users/naco/Documents/retain/.output/server/chunks/app/server.mjs
Did you mean to import tslib/tslib.js?
  at new NodeError (node:internal/errors:399:5)  
  at finalizeResolution (node:internal/modules/esm/resolve:326:11)  
  at moduleResolve (node:internal/modules/esm/resolve:945:10)  
  at defaultResolve (node:internal/modules/esm/resolve:1153:11)  
  at nextResolve (node:internal/modules/esm/loader:163:28)  
  at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)  
  at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)  
  at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)  
  at link (node:internal/modules/esm/module_job:76:36)

Expected behaviour

nuxt.config.ts

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  app: {
    head: {
      charset: 'utf-8',
      viewport: 'width=device-width, initial-scale=1',
    }
  },
  devtools: { enabled: true },
  srcDir:"./src",
  modules: ['@nuxtjs/apollo','@pinia/nuxt'],
  imports: {
    dirs: ['./store'],
  },
  pinia: {
    autoImports: ['defineStore', 'acceptHMRUpdate','storeToRefs'],
  },
  alias: {
    tslib: 'tslib'
  },
  apollo: {
    clients: {
      default: {
        httpEndpoint: 'https://api.nco.im/graphql'
      }
    },
  },
})

Reproduction

No response

Additional context

No response

Logs

No response

slavanossar commented 1 year ago

Likely due to this change to tslib exports, you can override the version to one that works

PNPM

{
 "pnpm": {
    "overrides": {
      "tslib": "2.5.1"
    }
  }
}

Yarn

{
  "resolutions": {
    "tslib": "2.5.1"
  }
}
NaCoLiu commented 1 year ago

@slavanossar thx bro.

slavanossar commented 1 year ago

@NaCoLiu I think leave this issue open, this module might need to be updated to use new exports from tslib so the issue needs to be tracked

oosame commented 1 year ago

@slavanossar any resolution for npm?

slavanossar commented 1 year ago

@oosame you can try pinning the version by adding the required version as a dependency

npm install tslib@2.5.1 --save-dev
markhacd commented 1 year ago

@oosame you can try pinning the version by adding the required version as a dependency

npm install tslib@2.5.1 --save-dev

thx bro.

FamilyMan commented 1 year ago

Also need to check that package.json has "type": "module"

iamandrewluca commented 1 year ago

@slavanossar any resolution for npm?

{
    "overrides": {
        "tslib": "2.5.1"
    }
}
iamandrewluca commented 1 year ago

Related issues:

Sina-Afsharmanesh commented 1 year ago

Any updates on this? It'd be nice if this gets fixed in v5 and we could use the latest version tslib, since some other libraries need it.

iamandrewluca commented 1 year ago

@Sina-Afsharmanesh check one of these solutions. Both should work.

https://github.com/nuxt/nuxt/issues/19265#issuecomment-1702014262

Xanndr-exe commented 12 months ago

just add to nuxt config

 build: {
    transpile: ['tslib']
  }