alloc / vite-plugin-compress

Compress your bundle + assets from Vite
MIT License
131 stars 13 forks source link

clean build fails on latest version of Vite #3

Open dlqqq opened 3 years ago

dlqqq commented 3 years ago

Steps to reproduce

Error

[vite:compress] setAssetSource cannot be called in transform for caching reasons. Use emitFile with a source, or call setAssetSource in another hook.
file: /home/hydrocodone/Repositories/vite-plugin-compress/demo/public/test.svg
error during build:
Error: setAssetSource cannot be called in transform for caching reasons. Use emitFile with a source, or call setAssetSource in another hook.
    at error (/home/hydrocodone/Repositories/vite-plugin-compress/node_modules/.pnpm/rollup@2.45.2/node_modules/rollup/dist/shared/rollup.js:5305:30)
    at throwPluginError (/home/hydrocodone/Repositories/vite-plugin-compress/node_modules/.pnpm/rollup@2.45.2/node_modules/rollup/dist/shared/rollup.js:18040:12)
    at Object.error (/home/hydrocodone/Repositories/vite-plugin-compress/node_modules/.pnpm/rollup@2.45.2/node_modules/rollup/dist/shared/rollup.js:18666:20)
    at Object.error (/home/hydrocodone/Repositories/vite-plugin-compress/node_modules/.pnpm/rollup@2.45.2/node_modules/rollup/dist/shared/rollup.js:18209:38)
    at Object.setAssetSource (/home/hydrocodone/Repositories/vite-plugin-compress/node_modules/.pnpm/rollup@2.45.2/node_modules/rollup/dist/shared/rollup.js:18228:29)
    at Object.transform (/home/hydrocodone/Repositories/vite-plugin-compress/dist/plugin.js:107:34)
    at async ModuleLoader.addModuleSource (/home/hydrocodone/Repositories/vite-plugin-compress/node_modules/.pnpm/rollup@2.45.2/node_modules/rollup/dist/shared/rollup.js:18403:30)
    at async ModuleLoader.fetchModule (/home/hydrocodone/Repositories/vite-plugin-compress/node_modules/.pnpm/rollup@2.45.2/node_modules/rollup/dist/shared/rollup.js:18459:9)
    at async Promise.all (index 1)
    at async ModuleLoader.fetchStaticDependencies (/home/hydrocodone/Repositories/vite-plugin-compress/node_modules/.pnpm/rollup@2.45.2/node_modules/rollup/dist/shared/rollup.js:18485:34)
 ERROR  Command failed with exit code 1.

This could be caused by recent breaking change in Vite v2.3.0. Will submit PR for review.

aleclarson commented 3 years ago

Thanks for investigating! Awaiting your PR :)

wtachau commented 3 years ago

Any update here? We're having this same issue!

muuvmuuv commented 3 years ago

Same issue here :/

aleclarson commented 3 years ago

It's fixed on the next branch, but the fix depends on #1675, which I haven't had time to write tests for.