Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[plugin:suid] traverse is not a function. (In 'traverse(ast, { #297

Open
cysabi opened this issue Jul 19, 2024 · 0 comments
Open

[plugin:suid] traverse is not a function. (In 'traverse(ast, { #297

cysabi opened this issue Jul 19, 2024 · 0 comments

Comments

@cysabi
Copy link

cysabi commented Jul 19, 2024

When running the vite dev server programmatically, the suid plugin fails to activate.
Running vite dev from the command line does not have these problems

const createViteServer = (await import("vite")).createServer;
const vite = await createViteServer();
[plugin:suid] traverse is not a function. (In 'traverse(ast, {
    enter(path) {
      const { node } = path;
      if (!(types.isImportDeclaration(node) && options.optimizeImports.paths.some((v) => v === node.source.value)))
        return;
      const imports = node.specifiers.map((spec) => {
        if (types.isImportSpecifier(spec) && types.isIdentifier(spec.imported) && types.isIdentifier(spec.local))
          return getOptimizedImportPath(node.source.value, spec.imported.name, spec.local.name);
      }).filter((v) => !!v);
      path.replaceWithMultiple(imports.map((item) => types.importDeclaration(typeof item.specifier === "string" ? [types.importDefaultSpecifier(types.identifier(item.specifier))] : [
        ...Object.entries(item.specifier).map(([alias, specifier]) => types.importSpecifier(types.identifier(specifier), types.identifier(alias)))
      ], types.stringLiteral(item.path))));
    }
  })', 'traverse' is undefined)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant