Skip to content

Commit

Permalink
Merge branch 'main' into monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
louisgv authored Jan 29, 2024
2 parents 0d45f7e + 1cb290e commit 278ee50
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 43 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"files.exclude": {
"**/.git": true,
"**/.svn": true,
Expand Down
2 changes: 1 addition & 1 deletion core/parcel-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@plasmohq/parcel-config",
"version": "0.40.1",
"version": "0.40.2",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion core/parcel-resolver-post/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@plasmohq/parcel-resolver-post",
"version": "0.4.2",
"version": "0.4.3",
"description": "Plasmo Parcel Resolver Post-processing",
"files": [
"dist"
Expand Down
18 changes: 15 additions & 3 deletions core/parcel-resolver-post/src/handle-ts-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function handleTsPath(
props: ResolverProps
): Promise<ResolverResult> {
try {
const { dependency } = props
const { dependency, specifier } = props

checkWebpackSpecificImportSyntax(dependency.specifier)

Expand All @@ -61,6 +61,15 @@ export async function handleTsPath(
return null
}

if (specifier.startsWith(".")) {
return {
filePath: findModule(
resolve(dependency.resolveFrom, "..", specifier),
relevantExtList
)
}
}

const compilerOptions = await getTsconfigCompilerOptions(props)

if (compilerOptions.length === 0) {
Expand Down Expand Up @@ -89,8 +98,10 @@ function loadTsPathsMap(tsConfigs: TSConfig[]) {
return
}

const tsPathsMap = new Map<string, TsPaths>()
tsConfigs.forEach((tsConfig) => loadPathsFromTSConfig(tsConfig, tsPathsMap))
const tsPathsMap = tsConfigs.reduce(
(c, tsConfig) => loadPathsFromTSConfig(tsConfig, c),
new Map<string, TsPaths>()
)

state.pathsMap = tsPathsMap
state.pathsMapRegex = Array.from(tsPathsMap.entries()).map((entry) => [
Expand All @@ -116,6 +127,7 @@ function loadPathsFromTSConfig(
tsPaths[key].map((p) => join(tsConfigFolderPath, p))
)
}
return tsPathsMap
}

function attemptResolve({ specifier, dependency }: ResolverProps) {
Expand Down
2 changes: 1 addition & 1 deletion core/parcel-resolver/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@plasmohq/parcel-resolver",
"version": "0.13.1",
"version": "0.13.2",
"description": "Plasmo Parcel Resolver",
"files": [
"dist"
Expand Down
19 changes: 16 additions & 3 deletions core/parcel-resolver/src/handle-tilde-src.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { extname, resolve } from "path"
import { extname, join, resolve } from "path"

import {
relevantExtensionList,
Expand All @@ -9,6 +9,7 @@ import {
} from "./shared"

export async function handleTildeSrc({
pipeline,
specifier,
dependency
}: ResolverProps): Promise<ResolverResult> {
Expand All @@ -17,10 +18,22 @@ export async function handleTildeSrc({
}

const absoluteBaseFile = resolve(
process.env.PLASMO_SRC_DIR,
specifier.slice(1)
join(process.env.PLASMO_SRC_DIR, specifier.slice(1))
)

if (
pipeline === "data-text" ||
pipeline === "data-base64" ||
pipeline === "data-env" ||
pipeline === "data-text-env" ||
pipeline === "raw" ||
pipeline === "raw-env"
) {
return {
filePath: absoluteBaseFile
}
}

const importExt = extname(absoluteBaseFile)

// TODO: Potentially resolve other type of files (less import etc...) that Parcel doesn't account for
Expand Down
2 changes: 1 addition & 1 deletion core/parcel-transformer-inline-css/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@plasmohq/parcel-transformer-inline-css",
"version": "0.3.10",
"version": "0.3.11",
"description": "Plasmo Parcel Transformer for inline CSS",
"files": [
"dist"
Expand Down
4 changes: 2 additions & 2 deletions core/parcel-transformer-inline-css/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2023 Plasmo Corp. <[email protected]> (https://www.plasmo.com) and contributors
* Copyright (c) 2024 Plasmo Corp. <[email protected]> (https://www.plasmo.com) and contributors
* MIT License
*
* Based on: https://github.com/parcel-bundler/parcel/blob/7023c08b7e99a9b8fd3c04995e4ef7ca92dee5c1/packages/transformers/css/src/CSSTransformer.js
Expand Down Expand Up @@ -33,7 +33,7 @@ export default new Transformer({
sourceMap: !!asset.env.sourceMap
})

asset.setBuffer(res.code)
asset.setBuffer(Buffer.from(res.code))

if (res.dependencies) {
for (let dep of res.dependencies) {
Expand Down
2 changes: 1 addition & 1 deletion core/parcel-transformer-manifest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@plasmohq/parcel-transformer-manifest",
"version": "0.17.8",
"version": "0.17.9",
"description": "Plasmo Parcel Transformer for Web Extension Manifest",
"files": [
"dist",
Expand Down
5 changes: 2 additions & 3 deletions core/parcel-transformer-manifest/src/handle-background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ function handleFirefoxMV3Background(program: MV3Data) {

function handleMV2BackgroundScript(program: MV2Data) {
const { hot, asset } = getState()
vLog(`Handling background scripts`)

if (program.background?.scripts) {
vLog(`Handling MV2 background scripts`)
program.background.scripts = program.background.scripts.map((bgScript) =>
asset.addURLDependency(bgScript, {
bundleBehavior: "isolated",
Expand All @@ -79,10 +79,9 @@ function handleMV2BackgroundScript(program: MV2Data) {

function handleMV3BackgroundServiceWorker(program: MV3Data) {
const { hot, asset, filePath, ptrs } = getState()
vLog(`Handling background scripts`)

if (program.background?.service_worker) {
vLog(`Handling background service worker`)
vLog(`Handling MV3 background service worker`)
program.background.service_worker = asset.addURLDependency(
program.background.service_worker,
{
Expand Down
2 changes: 2 additions & 0 deletions core/parcel-transformer-manifest/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ export default new Transformer({

state.asset.setCode(JSON.stringify(data, null, 2))
state.asset.meta.webextEntry = true

vLog("+ Finished transforming manifest")
return state.getAssets()
}
})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@
"npm": ">=9.5.0",
"node": ">=18.0.0"
},
"packageManager": "pnpm@8.14.1"
"packageManager": "pnpm@8.15.0"
}
Loading

0 comments on commit 278ee50

Please sign in to comment.