Make it compatible with vite V6
It would be great to upgrade to the latest version of vite and still be able to use this plugin.
@aleksolutions , are you getting errors? I just upgraded to vite 6.2.2 and it seems to be working fine for me.
@jdkdev I don't have any errors compiling but in dev mode.
VITE v6.2.2 ready in 251 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h + enter to show help
node:internal/fs/promises:1202
validateStringAfterArrayBufferView(data, 'data');
^
TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
at writeFile (node:internal/fs/promises:1202:5)
at DevBuilderManifestV3.writeManifestAssetFile (file:///C:/Users/alexs/projects/personal/node_modules/.pnpm/@samrum+vite-plugin-web-ext_49470b7512ed1e6a9268b937ec70ddec/node_modules/@samrum/vite-plugin-web-extension/dist/index.mjs:282:11)
at async DevBuilderManifestV3.writeManifestContentCssFiles (file:///C:/Users/alexs/projects/personal/node_modules/.pnpm/@samrum+vite-plugin-web-ext_49470b7512ed1e6a9268b937ec70ddec/node_modules/@samrum/vite-plugin-web-extension/dist/index.mjs:261:9)
at async DevBuilderManifestV3.writeBuild (file:///C:/Users/alexs/projects/personal/node_modules/.pnpm/@samrum+vite-plugin-web-ext_49470b7512ed1e6a9268b937ec70ddec/node_modules/@samrum/vite-plugin-web-extension/dist/index.mjs:159:5)
at async ManifestV3.writeDevBuild (file:///C:/Users/alexs/projects/personal/node_modules/.pnpm/@samrum+vite-plugin-web-ext_49470b7512ed1e6a9268b937ec70ddec/node_modules/@samrum/vite-plugin-web-extension/dist/index.mjs:473:5) {
code: 'ERR_INVALID_ARG_TYPE'
}
humm... some differences between our setups is I'm using npm and linux and looks like you're one pnpm/Windows.
Not sure what would cause the issue, can you share your vite config?
Happens the same in linux/macos.
Here is my vite config:
import webExtension from '@samrum/vite-plugin-web-extension'
import react from '@vitejs/plugin-react'
import { resolve } from 'path'
import { defineConfig, loadEnv } from 'vite'
import zipPack from 'vite-plugin-zip-pack'
import pkg from './package.json'
import { getManifest } from './src/manifest'
export type Browser = 'chrome' | 'firefox' | undefined
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const browser = (env.BROWSER ?? 'chrome') as Browser
const shouldZip = env.ZIP === 'true'
const extensionVersion = pkg.version
return {
base: '',
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler'
}
}
},
resolve: {
alias: {
'@': resolve(__dirname, './src')
}
},
server: {
cors: {
methods: 'GET',
origin: '*'
}
},
plugins: [
react(),
webExtension({
manifest: getManifest(browser),
useDynamicUrlWebAccessibleResources: false
}),
shouldZip &&
zipPack({
outDir: 'releases',
outFileName: `${browser}-release-${extensionVersion}.zip`
})
]
}
})
what does src/manifest file look like?
TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
I have the same error in dev, fixed by downgrading vite to 5.x.
Works fine for me on vite 6.2.2. However, I'm not using pnpm . I've tried Vanilla, React, TypeScript options, everything compiles and runs with no errors.
I see this too. Just upgraded to [email protected]. Using npm, manifest defined in TS.
I have a TS error in vite.config.ts (defineConfig):
Type 'import("/my-ext/path/node_modules/@samrum/vite-plugin-web-extension/node_modules/vite/dist/node/index").PluginOption' is not assignable to type 'import("/my-ext/path/node_modules/vite/dist/node/index").PluginOption'.
Type 'PluginOption[]' is not assignable to type 'PluginOption'