swordev / suid

A port of Material-UI (MUI) built with SolidJS.
https://suid.io
MIT License
682 stars 49 forks source link

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

Open cysabi opened 4 months ago

cysabi commented 4 months ago

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)