Skip to content

Transform to VSCode Worker File #15511

Closed Answered by cemalgnlts
cemalgnlts asked this question in Q&A
Discussion options

You must be logged in to vote

Fixed.

function extensionWorkerTranformer(): PluginOption {
  const Provider: Plugin = {
    name: "VSCodeExtensionProvier",
    setup(build) {
      build.onLoad({ filter: /\.wasm$/ }, (args) => {
        // @ts-expect-error process is node global namespace?
        const path = args.path.replace(process.cwd(), "");

        return {
          contents: `export default "${path}";`,
        };
      });
    },
  };

  return {
    name: "ExtensionWorker",
    enforce: "post",
    apply: () => true,
    async transform(code, id) {
      if (/extensions\/[\w]+\/worker.ts$/.test(id)) {
        const {
          outputFiles: [file],
        } = await build({
          // stdin: { contents: co…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by cemalgnlts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant