From a3713356ef3affff5c885f0589cd46d372d496d1 Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Sat, 31 Dec 2022 17:26:04 +0800 Subject: [PATCH] feat: supports js extension for content and sandbox (#371) * feat: supports js extension for content and sandbox * flatten it further Co-authored-by: Louis <6723574+louisgv@users.noreply.github.com> --- .../features/extension-devtools/project-path.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/cli/plasmo/src/features/extension-devtools/project-path.ts b/cli/plasmo/src/features/extension-devtools/project-path.ts index 399998688..41d67cc69 100644 --- a/cli/plasmo/src/features/extension-devtools/project-path.ts +++ b/cli/plasmo/src/features/extension-devtools/project-path.ts @@ -52,19 +52,16 @@ export const getProjectPath = ( /** * only pointing to 1 particular file path */ - const getModuleList = (moduleName: string) => [ - resolve(sourceDirectory, `${moduleName}.ts`), - resolve(sourceDirectory, `${moduleName}.${browserTarget}.ts`), - ...uiExts.flatMap((uiExt) => [ - resolve(sourceDirectory, `${moduleName}${uiExt}`), - resolve(sourceDirectory, `${moduleName}.${browserTarget}${uiExt}`) + const getModuleList = (moduleName: string) => + [".ts", ...uiExts, ".js"].flatMap((ext) => [ + resolve(sourceDirectory, `${moduleName}${ext}`), + resolve(sourceDirectory, `${moduleName}.${browserTarget}${ext}`) ]) - ] /** * crawl index, and only care about one extension */ - const getIndexList = (moduleName: string, exts = [".ts"]) => + const getIndexList = (moduleName: string, exts = [".ts", ".js"]) => exts.flatMap((ext) => [ resolve(sourceDirectory, `${moduleName}.${browserTarget}${ext}`), resolve(sourceDirectory, moduleName, `index.${browserTarget}${ext}`), @@ -89,7 +86,7 @@ export const getProjectPath = ( resolve(sourceDirectory, ".env.development.local") ] - const backgroundIndexList = getIndexList("background", [".ts", ".js"]) + const backgroundIndexList = getIndexList("background") const contentIndexList = getModuleList("content") const sandboxIndexList = getModuleList("sandbox")