lib icon indicating copy to clipboard operation
lib copied to clipboard

__vite_ssr_import_1__.loadTranslations is not a function

Open mactanxin opened this issue 3 years ago • 5 comments

Hi, I'm running into issues with this error every time, not sure what's wrong. I followed the README and the Multi-Page Example.

every time with hot reload will run into

__vite_ssr_import_1__.loadTranslations is not a function
TypeError: __vite_ssr_import_1__.loadTranslations is not a function
    at load (__layout.svelte:11:26)
    at load_node (file://home/tailwind-cms/node_modules/@sveltejs/kit/dist/chunks/index.js:1610:30)
    at respond$1 (file://home/tailwind-cms/node_modules/@sveltejs/kit/dist/chunks/index.js:1812:21)
    at async render_page (file://home/tailwind-cms/node_modules/@sveltejs/kit/dist/chunks/index.js:2003:19)
    at async resolve (file://home/tailwind-cms/node_modules/@sveltejs/kit/dist/chunks/index.js:2159:10)
    at async Object.handle (//Users/xintan/Workspace/Ailink/code/ailink-tailwind-cms/src/hooks:8:19)
    at async respond (file://home/tailwind-cms/node_modules/@sveltejs/kit/dist/chunks/index.js:2123:20)
    at async file://home/tailwind-cms/node_modules/@sveltejs/kit/dist/chunks/index.js:2461:24

then

Error when evaluating SSR module /src/lib/locale/index.js:
TypeError: Class extends value #<Object> is not a constructor or null
    at Object.<anonymous> (/home/tailwind-cms/node_modules/sveltekit-i18n/dist/index.cjs:1:1446)
    at Module._compile (node:internal/modules/cjs/loader:1109:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
    at Module.load (node:internal/modules/cjs/loader:989:32)
    at Function.Module._load (node:internal/modules/cjs/loader:829:14)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:201:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:175:25)
    at async Loader.import (node:internal/modules/esm/loader:178:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
    at async nodeImport (/home/tailwind-cms/node_modules/vite/dist/node/chunks/dep-f5552faa.js:60169:21)

here's my Package file:

"devDependencies": {
    "@sveltejs/adapter-auto": "next",
    "@sveltejs/adapter-static": "^1.0.0-next.26",
    "@sveltejs/kit": "next",
    "autoprefixer": "^10.4.2",
    "eslint": "^7.32.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-svelte3": "^3.2.1",
    "postcss": "^8.4.5",
    "prettier": "^2.4.1",
    "prettier-plugin-svelte": "^2.4.0",
    "svelte": "^3.44.3",
    "tailwindcss": "^3.0.17"
  },
  "type": "module",
  "dependencies": {
    "@fontsource/fira-mono": "^4.5.0",
    "@lukeed/uuid": "^2.0.0",
    "cookie": "^0.4.1",
    "sveltekit-i18n": "^2.0.0-rc.0"
  }

mactanxin avatar Feb 09 '22 03:02 mactanxin

for now, I have to stop and restart the dev server, refresh the browser then everything works fine.

Just a quick update:

after downgrade to 1.5.4, everything works fine :)

mactanxin avatar Feb 09 '22 03:02 mactanxin

I think there is something wrong with the rc.0 version - could you, please try now with the latest one? Thanks!

jarda-svoboda avatar Feb 09 '22 09:02 jarda-svoboda

Ok, i can verify that RC versions (at least of sveltekit-i18n lib) does not work as they should.. Needs to be fixed...

Getting with @2.0.0-rc.3:

500
Class extends value #<Object> is not a constructor or null
TypeError: Class extends value #<Object> is not a constructor or null

Update: This seems to be related to CJS version only – as a quick workaround you could just delete ./node_modules/sveltekit-i18n/dist/index.cjs or use a stable version 1.5.4..

jarda-svoboda avatar Feb 09 '22 10:02 jarda-svoboda

Ok, it seems like an error in bundler. I've reported this issue here: https://github.com/egoist/tsup/issues/567

jarda-svoboda avatar Feb 09 '22 13:02 jarda-svoboda

Added temporary workaround in [email protected]

jarda-svoboda avatar Feb 09 '22 14:02 jarda-svoboda

Fixed by splitting: true tsup option.

jarda-svoboda avatar Jul 09 '23 23:07 jarda-svoboda