Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: supports js extension for content and sandbox #371

Merged
merged 2 commits into from
Dec 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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