Skip to content

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

@cysabi

Description

@cysabi

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions