PlasmoHQ / plasmo

🧩 The Browser Extension Framework
https://www.plasmo.com
MIT License
10.53k stars 366 forks source link

[RFC] Re-export CS config and reuse it #753

Open addlistener opened 1 year ago

addlistener commented 1 year ago

What happened?

🟠 WARN   | [plasmo/parcel-runtime]: @plasmohq/parcel-transformer-manifest: Got unexpected undefined
Error: Got unexpected undefined
    at nullthrows (/path/to/proj/node_modules/.pnpm/nullthrows@1.1.1/node_modules/nullthrows/nullthrows.js:7:15)
    at /path/to/proj/node_modules/.pnpm/@parcel+diagnostic@2.9.3/node_modules/@parcel/diagnostic/lib/diagnostic.js:156:41
    at Array.map (<anonymous>)
    at generateJSONCodeHighlights (/path/to/proj/node_modules/.pnpm/@parcel+diagnostic@2.9.3/node_modules/@parcel/diagnostic/lib/diagnostic.js:151:14)
    at $4ca1027d34905147$var$validateSchema.diagnostic (/path/to/proj/node_modules/.pnpm/@parcel+utils@2.9.3/node_modules/@parcel/utils/lib/index.js:34634:88)
    at Object.transform (/path/to/proj/node_modules/.pnpm/@plasmohq+parcel-transformer-manifest@0.17.8/node_modules/@plasmohq/parcel-transformer-manifest/dist/index.js:1:17252)
    at async Transformation.runTransformer (/path/to/proj/node_modules/.pnpm/@parcel+core@2.9.3/node_modules/@parcel/core/lib/Transformation.js:568:5)
    at async Transformation.runPipeline (/path/to/proj/node_modules/.pnpm/@parcel+core@2.9.3/node_modules/@parcel/core/lib/Transformation.js:346:36)
    at async Transformation.runPipelines (/path/to/proj/node_modules/.pnpm/@parcel+core@2.9.3/node_modules/@parcel/core/lib/Transformation.js:229:40)
    at async Transformation.run (/path/to/proj/node_modules/.pnpm/@parcel+core@2.9.3/node_modules/@parcel/core/lib/Transformation.js:149:21)

The complaining code contents/config.ts. The results are the same for export const config in content.ts

import type {PlasmoCSConfig} from "plasmo";

const config: PlasmoCSConfig = {
  "matches": ["<all_urls>"],
  "run_at": "document_end" 
};

export default config;

The config is parsed but the rest of the code does not run because of the bug

🟡 134    | Parsed config: { '"matches"': [ '<all_urls>' ], '"run_at"': 'document_end' }

We love plasmo but kinda have to migrate away from plasmo because we need this config...

Version

Latest

What OS are you seeing the problem on?

No response

What browsers are you seeing the problem on?

No response

Relevant log output

No response

(OPTIONAL) Contribution

Code of Conduct

louisgv commented 1 year ago

The config are parsed statically - it's not meant for re-exported (since it will be read by the compiler). Think of this as the "entry" file.

On that note - PR is welcome to implement this! - it'd be pretty challenging I think :d