Skip to content

how to prevent export default changing to random named export #16332

Answered by ogios
ogios asked this question in Q&A
Discussion options

You must be logged in to vote

just wrote a script myself which can help me do it, but if there's a better way, i'm glad to know

the script

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";

function getLocaleMap() {
  const cwd = "./src/components/i18n/lang/";
  const resList = Array.from(
    new Bun.Glob("*.ts").scanSync({
      cwd,
    }),
  ).map((v) => path.join(cwd, v));

  const resMap: Record<string, string> = {};
  const tsPattern = /(.*)\.ts$/i;
  resList.forEach((v) => {
    console.log(v);
    const name = "locale_" + path.basename(v).replace(tsPattern, "$1");
    resMap[name] = v;
  });

  console.log(resMap);
  return resMap;
}

function matchLocaleLang(

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ogios
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