crxjs / chrome-extension-tools

Bundling Chrome Extensions can be pretty complex. It doesn't have to be.
https://crxjs.dev/vite-plugin
2.98k stars 192 forks source link

Minimal Solidjs Getting Start Example Still Broken with Beta 4 #567

Closed promethyttrium closed 2 years ago

promethyttrium commented 2 years ago

Build tool

Vite

Where do you see the problem?

Describe the bug

Just following the example as documented here for Typescript

https://crxjs.dev/vite-plugin/getting-started/solid/create-project

Reproduction

npx degit solidjs/templates/ts vite-solid-crxjs

npm i @crxjs/vite-plugin@beta -D # this installs beta-4 as indicates below by packages.json

# edit files as indicated below

vite.config.ts

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 })
  ],
})

packages.json

{
  "name": "vite-template-solid",
  "version": "0.0.0",
  "description": "",
  "scripts": {
    "start": "vite",
    "dev": "vite",
    "build": "vite build",
    "serve": "vite preview"
  },
  "license": "MIT",
  "devDependencies": {
    "@crxjs/vite-plugin": "^2.0.0-beta.4",
    "typescript": "^4.8.2",
    "vite": "^3.0.9",
    "vite-plugin-solid": "^2.3.0"
  },
  "dependencies": {
    "solid-js": "^1.5.1"
  }
}

manifest.json

{
  "manifest_version": 3,
  "name": "CRXJS Solid Vite Example",
  "version": "1.0.0",
  "action": { "default_popup": "index.html" }
}

Logs

> vite-template-solid@0.0.0 build
> vite build

X [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.

    node_modules/esbuild/lib/main.js:1327:27:
      1327 │         let result = await callback({
           ╵                            ^

    at packageEntryFailure (file:///E:/.develop/.sandbox/try-solidjs-vite-chrome-extension-10282022/vite-solid-crxjs-beta4/node_modules/vite/dist/node/chunks/dep-c842e491.js:35293:11)
    at resolvePackageEntry (file:///E:/.develop/.sandbox/try-solidjs-vite-chrome-extension-10282022/vite-solid-crxjs-beta4/node_modules/vite/dist/node/chunks/dep-c842e491.js:35290:5)
    at tryNodeResolve (file:///E:/.develop/.sandbox/try-solidjs-vite-chrome-extension-10282022/vite-solid-crxjs-beta4/node_modules/vite/dist/node/chunks/dep-c842e491.js:35031:20)
    at file:///E:/.develop/.sandbox/try-solidjs-vite-chrome-extension-10282022/vite-solid-crxjs-beta4/node_modules/vite/dist/node/chunks/dep-c842e491.js:63965:40
    at requestCallbacks.on-resolve (E:\.develop\.sandbox\try-solidjs-vite-chrome-extension-10282022\vite-solid-crxjs-beta4\node_modules\esbuild\lib\main.js:1327:28)
    at handleRequest (E:\.develop\.sandbox\try-solidjs-vite-chrome-extension-10282022\vite-solid-crxjs-beta4\node_modules\esbuild\lib\main.js:697:19)
    at handleIncomingPacket (E:\.develop\.sandbox\try-solidjs-vite-chrome-extension-10282022\vite-solid-crxjs-beta4\node_modules\esbuild\lib\main.js:719:7)
    at Socket.readFromStdout (E:\.develop\.sandbox\try-solidjs-vite-chrome-extension-10282022\vite-solid-crxjs-beta4\node_modules\esbuild\lib\main.js:647:7)
    at Socket.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:315:12)

  This error came from the "onResolve" callback registered here:

    node_modules/esbuild/lib/main.js:1251:20:
      1251 │       let promise = setup({
           ╵                     ^

    at setup (file:///E:/.develop/.sandbox/try-solidjs-vite-chrome-extension-10282022/vite-solid-crxjs-beta4/node_modules/vite/dist/node/chunks/dep-c842e491.js:63955:27)
    at handlePlugins (E:\.develop\.sandbox\try-solidjs-vite-chrome-extension-10282022\vite-solid-crxjs-beta4\node_modules\esbuild\lib\main.js:1251:21)
    at buildOrServeImpl (E:\.develop\.sandbox\try-solidjs-vite-chrome-extension-10282022\vite-solid-crxjs-beta4\node_modules\esbuild\lib\main.js:942:5)
    at Object.buildOrServe (E:\.develop\.sandbox\try-solidjs-vite-chrome-extension-10282022\vite-solid-crxjs-beta4\node_modules\esbuild\lib\main.js:750:5)
    at E:\.develop\.sandbox\try-solidjs-vite-chrome-extension-10282022\vite-solid-crxjs-beta4\node_modules\esbuild\lib\main.js:2085:17
    at new Promise (<anonymous>)
    at Object.build (E:\.develop\.sandbox\try-solidjs-vite-chrome-extension-10282022\vite-solid-crxjs-beta4\node_modules\esbuild\lib\main.js:2084:14)
    at build (E:\.develop\.sandbox\try-solidjs-vite-chrome-extension-10282022\vite-solid-crxjs-beta4\node_modules\esbuild\lib\main.js:1931:51)
    at bundleConfigFile (file:///E:/.develop/.sandbox/try-solidjs-vite-chrome-extension-10282022/vite-solid-crxjs-beta4/node_modules/vite/dist/node/chunks/dep-c842e491.js:63918:26)

  The plugin "externalize-deps" was triggered by this import

    vite.config.ts:15:20:
      15 │ import { crx } from '@crxjs/vite-plugin';
         ╵                     ~~~~~~~~~~~~~~~~~~~~

failed to load config from E:\.develop\.sandbox\try-solidjs-vite-chrome-extension-10282022\vite-solid-crxjs-beta4\vite.config.ts
error during build:
Error: Build failed with 1 error:
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.
    at failureErrorWithLog (E:\.develop\.sandbox\try-solidjs-vite-chrome-extension-10282022\vite-solid-crxjs-beta4\node_modules\esbuild\lib\main.js:1566:15)
    at E:\.develop\.sandbox\try-solidjs-vite-chrome-extension-10282022\vite-solid-crxjs-beta4\node_modules\esbuild\lib\main.js:1024:28
    at runOnEndCallbacks (E:\.develop\.sandbox\try-solidjs-vite-chrome-extension-10282022\vite-solid-crxjs-beta4\node_modules\esbuild\lib\main.js:1438:61)
    at buildResponseToResult (E:\.develop\.sandbox\try-solidjs-vite-chrome-extension-10282022\vite-solid-crxjs-beta4\node_modules\esbuild\lib\main.js:1022:7)
    at E:\.develop\.sandbox\try-solidjs-vite-chrome-extension-10282022\vite-solid-crxjs-beta4\node_modules\esbuild\lib\main.js:1134:14
    at responseCallbacks.<computed> (E:\.develop\.sandbox\try-solidjs-vite-chrome-extension-10282022\vite-solid-crxjs-beta4\node_modules\esbuild\lib\main.js:671:9)
    at handleIncomingPacket (E:\.develop\.sandbox\try-solidjs-vite-chrome-extension-10282022\vite-solid-crxjs-beta4\node_modules\esbuild\lib\main.js:726:9)
    at Socket.readFromStdout (E:\.develop\.sandbox\try-solidjs-vite-chrome-extension-10282022\vite-solid-crxjs-beta4\node_modules\esbuild\lib\main.js:647:7)
    at Socket.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:315:12)

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (12) x64 Intel(R) Core(TM) i7-5820K CPU @ 3.30GHz   
    Memory: 5.20 GB / 15.90 GB
  Binaries:
    Node: 16.10.0 - C:\Program Files\nodejs\node.EXE
    npm: 7.24.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 106.0.5249.121
    Edge: Spartan (44.19041.1266.0), Chromium (107.0.1418.26)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    @crxjs/vite-plugin: ^2.0.0-beta.4 => 2.0.0-beta.4        
    vite: ^3.0.9 => 3.2.2

Severity

blocking all usage of RPCE

jacksteamdev commented 2 years ago

@promethyttrium For now, add "type": "module" to the package.json file:

{
  "name": "vite-template-solid",
+ "type": "module",
  "version": "0.0.0",
  "description": "",
  "scripts": {
    "start": "vite",
    "dev": "vite",
    "build": "vite build",
    "serve": "vite preview"
  },
  "license": "MIT",
  "devDependencies": {
    "@crxjs/vite-plugin": "^2.0.0-beta.4",
    "typescript": "^4.8.2",
    "vite": "^3.0.9",
    "vite-plugin-solid": "^2.3.0"
  },
  "dependencies": {
    "solid-js": "^1.5.1"
  }
}
jacksteamdev commented 2 years ago

I've added the "type": "module" tip to the docs.