richardtallent / vite-plugin-singlefile

Vite plugin for inlining JavaScript and CSS resources
MIT License
808 stars 53 forks source link

Requires Node >= 15 #60

Closed bravecrayon closed 1 year ago

bravecrayon commented 1 year ago

When using Node 14 I get this error:

[vite:singlefile] scriptCode.replaceAll is not a function
error during build:
TypeError: scriptCode.replaceAll is not a function
    at replaceScript (file:///Users/username/Projects/project/node_modules/vite-plugin-singlefile/dist/esm/index.js:7:32)
    at Object.generateBundle (file:///Users/username/Projects/project/node_modules/vite-plugin-singlefile/dist/esm/index.js:36:44)
    at file:///Users/username/Projects/project/node_modules/rollup/dist/es/shared/rollup.js:22710:40
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

Doing some googling it turns out replaceAll() wasn't introduced until Node 15. I upgraded to 16 and it works now.

It's a pretty easy fix since 16 is the latest LTS, but I just wanted to report it in case anyone else is searching for the issue like I was.

richardtallent commented 1 year ago

Yes, this plugin was originally intended (and is only tested) for use with Vue, and Vue requires 16+.