Skip to content

Commit

Permalink
feat: supports js extension for content and sandbox (#371)
Browse files Browse the repository at this point in the history
* feat: supports js extension for content and sandbox

* flatten it further

Co-authored-by: Louis <[email protected]>
  • Loading branch information
pd4d10 and louisgv committed Dec 31, 2022
1 parent 2d3f9b4 commit a371335
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions cli/plasmo/src/features/extension-devtools/project-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`),
Expand All @@ -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")
Expand Down

0 comments on commit a371335

Please sign in to comment.