Closed Joshuabaker2 closed 2 years ago
Looks like get-port
is an ESM-only package, so it doesn't work with the CommonJS build of CRXJS.
Surprising that I haven't seen this before. Are you using the Vite starter? If not, mind sharing your tsconfig.json
?
failed to load config from /
/vite.config.js
Just noticed that it references a JS Vite config; I wonder why?
Sorry the vite.config.js
is a red-herring, I must have run tsc
and it auto-converted the ts file, but if I delete the js
file and use just the ts
file the same thing happens.
I am using my own tsconfig as this package is part of a monorepo so there's some shared packages and configurations. Here's what it looks like:
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"inlineSources": true,
"isolatedModules": true,
"useUnknownInCatchVariables": false,
"lib": ["dom", "dom.iterable", "esnext", "scripthost", "es2020"],
"moduleResolution": "node",
"noUnusedLocals": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"target": "esnext",
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"emitDecoratorMetadata": true,
"baseUrl": "./",
"paths": {
"src/*": ["./src/*"],
"@fraction/shared": ["../packages/shared"]
},
"include": [
"./src/**/*"
],
"exclude": ["node_modules"],
"useDefineForClassFields": true,
"allowJs": false,
"module": "ESNext",
"noEmit": true,
"jsx": "react-jsx",
"jsxImportSource": "@emotion/react",
"types": ["chrome", "@emotion/react/types/css-prop", "vite/client"]
},
"references": [{ "path": "../shared" }, { "path": "./tsconfig.node.json" }]
}
and tsconfig.node.json
contains:
{
"compilerOptions": {
"composite": true,
"module": "esnext",
"moduleResolution": "node"
},
"include": ["vite.config.ts"]
}
Just reproduced this exact error, the minimal steps are just whatever is in https://crxjs.dev/vite-plugin/getting-started/solid/create-project
npx degit solidjs/templates/ts vite-solid-crxjs
npm i @crxjs/vite-plugin@beta -D # added the @beta part
# vite.config.js
import { defineConfig } from 'vite'
import solidPlugin from "vite-plugin-solid";
import { crx } from '@crxjs/vite-plugin'
import manifest from './manifest.json'
export default defineConfig({
plugins: [
solidPlugin(),
crx({ manifest })
],
});
# manifest.json
{
"manifest_version": 3,
"name": "CRXJS Solid Vite Example",
"version": "1.0.0",
"action": { "default_popup": "index.html" }
}
I would have thought the the minimum sanity test would be to make sure it works with the documentation's Getting Started steps... 🤦
So I updated to beta.4, but was getting a different crash. Ended up just changing my package to a module (with "type": "module"
in my package.json) and that resolved the crash.
For posterity, the crash I was getting as a commonjs project was:
yarn dev
✘ [ERROR] [plugin externalize-deps] Failed to resolve entry for package "@crxjs/vite-plugin". The package may have incorrect main/module/exports specified in its package.json.
../../.yarn/unplugged/esbuild-npm-0.15.9-37944ec582/node_modules/esbuild/lib/main.js:1327:27:
1327 │ let result = await callback({
and
failed to load config from /Users/josh/dev/fraction/dashboard/packages/chrome-extension/vite.config.ts
error when starting dev server:
Error: Build failed with 1 error:
../../.yarn/unplugged/esbuild-npm-0.15.9-37944ec582/node_modules/esbuild/lib/main.js:1327:27: ERROR: [plugin: externalize-deps] Failed to resolve entry for package "@crxjs/vite-plugin". The package may have incorrect main/module/exports specified in its package.json.
Build tool
Vite
Where do you see the problem?
Describe the bug
Note this only causes a crash in the 2.0.0-beta, it runs fine on 1.x. Tested it out on beta-1 and beta-3.
When running
vite
viayarn run dev
, I get the following error:Reproduction
It's a private repo, but I'll copy-paste the relevant config files:
package.json:
vite.config.ts
Logs
No response
System Info
Using yarn 4 with PnP.
Severity
blocking all usage of RPCE