live_vue icon indicating copy to clipboard operation
live_vue copied to clipboard

Changed package to an ES module

Open morfert opened this issue 1 year ago • 1 comments

I was getting vue ssr error module not found errors and ultimately ended up updating the package.json to be of "type": "module". This also required updating the import and export statements. The ssr errors have now stopped for me.

morfert avatar Jul 13 '24 03:07 morfert

Hi, thanks for your contribution! Let me look into this. I also tried making that change but in the end something didn't work properly. live_vue package is consumed by multiple clients:

  • Vite configuration
  • app.js
  • SSR bundle

and they have different requirements about ES modules (JS ecosystem is a fck mess when it comes to that).

Valian avatar Jul 18 '24 22:07 Valian

I'm closing this PR. After #32 I'm compiling all the files before publishing and they have now a consistent import / export usage.

Also, package.json explicitly says these files should be imported, not required:

"exports": {
        "./vitePlugin": {
            "import": "./priv/static/vitePlugin.js",
            "types": "./priv/static/vitePlugin.d.ts"
        },
        "./server": {
            "import": "./priv/static/server.js",
            "types": "./priv/static/server.d.ts"
        },
        ".": {
            "import": "./priv/static/index.js",
            "types": "./priv/static/index.d.ts"
        }
    }

Hopefully these should resolve all the errors!

Valian avatar Nov 01 '24 11:11 Valian