UstymUkhman / vite-plugin-glsl

:spider_web: Import, inline (and compress) GLSL shader files :electric_plug:
https://www.npmjs.com/package/vite-plugin-glsl
MIT License
321 stars 21 forks source link

Unable to import the plugin - missing tslib #2

Closed RoeelCohen closed 3 years ago

RoeelCohen commented 3 years ago

I have a simple VanillaJs Vite application running. Tried to add the glsl plugin but I'm getting the following issue after I run vite using npm:

package.json scripts:

 "scripts": {
    "dev": "vite --host",
    "build": "vite build",
    "serve": "vite preview"
  }

Error:

failed to load config from <PATH_TO_PROJECT>/threejs-test/vite.config.js
error when starting dev server:
Error: Cannot find module 'tslib'

Which seems a bit weird? since ts should be supported on vite without any configurations? Resorted to use the string loader which doesn't require additional modules

UstymUkhman commented 3 years ago

Hi @RoeelCohen! Thanks for opening this issue, I've reproduced it and you're totally right: as for now tslib module is required. As mentioned in README of tslib:

Because this can avoid duplicate declarations of things like extends, assign, etc., this means delivering users smaller files on average, as well as less runtime overhead. For optimized bundles with TypeScript, you should absolutely consider using tslib and --importHelpers.

So I'd like to keep it in vite-plugin-glsl as well. I think the only thing I'm missing here is to add it in dependencies of this project. I'm going to fix it ASAP. As for now, if you'd like to keep using vite-plugin-glsl in your vite vanilla js setup, one possible workaround is to add it manually in you package.json:

{
  "name": "vite-project",
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "serve": "vite preview"
  },
  "devDependencies": {
    "tslib": "^2.3.1",
    "vite": "^2.6.4",
    "vite-plugin-glsl": "^0.0.4"
  }
}
UstymUkhman commented 3 years ago

@RoeelCohen As mentioned above, I've updated this package and tested it with VanillaJS vite config. I'm closing this issue, but feel free to open another one if the problem persists or there's something else I've missed. Thanks for your feedback!