opral / inlang-paraglide-js

Tree-shakable i18n library build on the inlang ecosystem.
https://inlang.com/m/gerre34r/library-inlang-paraglideJs
42 stars 0 forks source link

Freshly generated project throws errors on start #54

Closed openscript closed 6 months ago

openscript commented 6 months ago

What I've done:

  1. Created a new Vite project.
  2. Initialized paraglide via pnpx @inlang/paraglide-js@latest init
  3. Added a vite.config.ts:

    import { defineConfig } from 'vite'
    import { paraglide } from '@inlang/paraglide-js-adapter-vite'
    
    export default defineConfig({
      plugins: [
        paraglide({
          project: './project.inlang', // Path to your inlang project
          outdir: './src/paraglide' // Where you want the generated files to be placed
        })
      ]
    })
  4. Started the project via pnpm dev and received:

      Using existing cloned repo
      Using existing cloned repo
      Using existing cloned repo
      node:internal/crypto/hash:104
          throw new ERR_INVALID_ARG_TYPE(
                ^
    
      TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
          at Hash.update (node:internal/crypto/hash:104:11)
          at hashMessages (file:///workspaces/slidev-theme-i18n/node_modules/.pnpm/@inlang+paraglide-js-adapter-unplugin@1.4.18/node_modules/@inlang/paraglide-js-adapter-unplugin/dist/index.js:90:10)
          at triggerCompile (file:///workspaces/slidev-theme-i18n/node_modules/.pnpm/@inlang+paraglide-js-adapter-unplugin@1.4.18/node_modules/@inlang/paraglide-js-adapter-unplugin/dist/index.js:21:37)
          at Context.buildStart (file:///workspaces/slidev-theme-i18n/node_modules/.pnpm/@inlang+paraglide-js-adapter-unplugin@1.4.18/node_modules/@inlang/paraglide-js-adapter-unplugin/dist/index.js:67:19)
          at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
          at async Promise.all (index 4)
          at async hookParallel (file:///workspaces/slidev-theme-i18n/node_modules/.pnpm/vite@5.2.7/node_modules/vite/dist/node/chunks/dep-C-KAszbv.js:50654:9)
          at async Object.buildStart (file:///workspaces/slidev-theme-i18n/node_modules/.pnpm/vite@5.2.7/node_modules/vite/dist/node/chunks/dep-C-KAszbv.js:51006:13)
          at async file:///workspaces/slidev-theme-i18n/node_modules/.pnpm/vite@5.2.7/node_modules/vite/dist/node/chunks/dep-C-KAszbv.js:64895:13
          at async httpServer.listen (file:///workspaces/slidev-theme-i18n/node_modules/.pnpm/vite@5.2.7/node_modules/vite/dist/node/chunks/dep-C-KAszbv.js:64913:17) {
        code: 'ERR_INVALID_ARG_TYPE'
      }
    
      Node.js v20.10.0

The project is here: https://github.com/openscript-ch/slidev-theme-i18n

LorisSigrist commented 6 months ago

Seems to be caused by a bug in the Inlang SDK. I've added some defensive coding to the vite plugin to make sure it can recover from it & work as expected