esbuild-plugin-ifdef
esbuild-plugin-ifdef copied to clipboard
error with windows path(used `\`)
When I first started using it, I get a error with esbuild.build({/* ... */}).catch(console.error):
Error: [#ifdef] "onLoad" filter is not a valid Go regular expression: "(C:\\Users\\xxx\\Documents\\test\\node_modules|C:\\Users\\xxx\\Documents\\test\\src).*\\.(js|ts|tsx)$"
After replacing \ with /, the plugin works:
const filter = {
filter: new RegExp(
`(${filterList
.map((dir) => path.join(_baseDir, dir))
.join("|").replace(/\\/g, "/")}).*\\.([jt]sx)$`
),
};
Please don't use the above code directly!! I don't actually know about this error, the above code is what I tried by coincidence