glromeo / esbuild-sass-plugin

esbuild plugin for sass
MIT License
155 stars 40 forks source link

onDispose is not a function #186

Closed wrmk closed 1 month ago

wrmk commented 3 months ago

Hi!

Recently I adapted the Rails project to compile CSS via esbuild, everything works great but I would like to reduce the time of the compilation. Because of that, I tried to use the embedded: true flag, but for some reason I've got the below error:

14:50:51 js_css.1 | ✘ [ERROR] [plugin sass-plugin] onDispose is not a function
14:50:51 js_css.1 | 
14:50:51 js_css.1 |     **/rails_project/node_modules/esbuild-sass-plugin/lib/render.js:35:8:
14:50:51 js_css.1 |       35 │         onDispose(compiler.dispose.bind(compiler));
14:50:51 js_css.1 |          ╵         ^
14:50:51 js_css.1 | 
14:50:51 js_css.1 |     at createCompiler (**/rails_project/node_modules/esbuild-sass-plugin/lib/render.js:35:9)
14:50:51 js_css.1 |     at async createRenderer (**/rails_projectnode_modules/esbuild-sass-plugin/lib/render.js:80:27)
14:50:51 js_css.1 |     at async setup (**/rails_project/node_modules/esbuild-sass-plugin/lib/plugin.js:52:32)
14:50:51 js_css.1 |     at async handlePlugins (**/rails_project/node_modules/esbuild/lib/main.js:897:11)

My plugin configuration:

sassPlugin({
  embedded: true,
  loadPaths: [
    "./node_modules",
  ],
  precompile: (source, pathname) => {
    return sassGlob(source, pathname);
  },
})

Maybe I'm doing something wrong, or there is a problem with the plugin, I don't know., but I'd like to start the conversation to get comments about this situation.

dungjk commented 1 month ago

Hello @wrmk Which version of esbuild you are using?. If you're using esbuild with version before @0.17.2 you may need to upgrade it.

wrmk commented 1 month ago

Hello @wrmk Which version of esbuild you are using?. If you're using esbuild with version before @0.17.2 you may need to upgrade it.

Hi! Yeah, my esbuild version is below 0.17.2. Will try, thank you.

wrmk commented 1 month ago

Hello @wrmk Which version of esbuild you are using?. If you're using esbuild with version before @0.17.2 you may need to upgrade it.

Hi! Yeah, my esbuild version is below 0.17.2. Will try, thank you.

it works! much appreciate