esbuild-plugin-ifdef icon indicating copy to clipboard operation
esbuild-plugin-ifdef copied to clipboard

error with windows path(used `\`)

Open oxy-plus opened this issue 4 years ago • 0 comments

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

oxy-plus avatar Oct 02 '21 19:10 oxy-plus