Skip to content

Commit 493253c

Browse files
committed
Generated by Spark: same issue on last run:
vite v5.4.19 building for production... transforming... ✓ 3 modules transformed. x Build failed in 92ms error during build: [vite]: Rollup failed to resolve import "@github/spark/spark" from "/home/runner/work/github-copilot-usage/github-copilot-usage/src/main.tsx". This is most likely unintended because it can break your application at runtime. If you do want to externalize this module explicitly add it to `build.rollupOptions.external` at viteWarn (file:///home/runner/work/github-copilot-usage/github-copilot-usage/node_modules/vite/dist/node/chunks/dep-C6uTJdX2.js:65839:17) at onwarn (file:///home/runner/work/github-copilot-usage/github-copilot-usage/node_modules/@vitejs/plugin-react/dist/index.mjs:282:9) at onRollupWarning (file:///home/runner/work/github-copilot-usage/github-copilot-usage/node_modules/vite/dist/node/chunks/dep-C6uTJdX2.js:65869:5) at onwarn (file:///home/runner/work/github-copilot-usage/github-copilot-usage/node_modules/vite/dist/node/chunks/dep-C6uTJdX2.js:65534:7) at file:///home/runner/work/github-copilot-usage/github-copilot-usage/node_modules/rollup/dist/es/shared/node-entry.js:20557:13 at Object.logger [as onLog] (file:///home/runner/work/github-copilot-usage/github-copilot-usage/node_modules/rollup/dist/es/shared/node-entry.js:22286:9) at ModuleLoader.handleInvalidResolvedId (file:///home/runner/work/github-copilot-usage/github-copilot-usage/node_modules/rollup/dist/es/shared/node-entry.js:21169:26) at file:///home/runner/work/github-copilot-usage/github-copilot-usage/node_modules/rollup/dist/es/shared/node-entry.js:21127:26 Error: Process completed with exit code 1.
1 parent 90a0d1c commit 493253c

5 files changed

Lines changed: 18 additions & 14 deletions

File tree

DEPLOYMENT.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ This will:
4848
## Configuration
4949

5050
- The application uses a special Vite configuration for GitHub Pages deployment (`vite.github-pages.config.ts`)
51-
- It uses a special version of the main.tsx file without Spark-specific dependencies
51+
- The `main-github-pages.tsx` file excludes Spark-specific imports that cause build issues
52+
- Build configuration excludes `@github/spark/spark` from bundling
5253
- Base URL is set to `'./'` to allow relative paths on GitHub Pages
5354

5455
## Troubleshooting
@@ -58,4 +59,5 @@ If you encounter deployment issues:
5859
1. Check the GitHub Actions workflow run for error messages
5960
2. Verify that GitHub Pages is properly configured in your repository settings
6061
3. Make sure all dependencies are properly installed
61-
4. Confirm that the GitHub Pages branch (gh-pages) is correctly set as the publishing source
62+
4. Confirm that the GitHub Pages branch (gh-pages) is correctly set as the publishing source
63+
5. Examine the build logs for errors related to missing dependencies

build-for-gh-pages.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# Copy the GitHub Pages specific main file
55
cp src/main-github-pages.tsx src/main.tsx
66

7-
# Build using Vite with the modified config
8-
npm run build
7+
# Build using Vite with the GitHub Pages config
8+
vite build --config vite.github-pages.config.ts
99

1010
# Restore the original main file if you need to continue local development
1111
git checkout src/main.tsx

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
"homepage": "./",
66
"type": "module",
77
"scripts": {
8-
"dev": "vite",
9-
"kill": "fuser -k 5000/tcp",
10-
"build": "tsc -b --noCheck && vite build",
11-
"lint": "eslint .",
12-
"optimize": "vite optimize",
13-
"preview": "vite preview",
14-
"build:pages": "cp src/main-github-pages.tsx src/main.tsx && vite build --config vite.github-pages.config.ts && git checkout src/main.tsx",
15-
"predeploy": "npm run build:pages",
16-
"deploy": "gh-pages -d dist"
17-
},
8+
"dev": "vite",
9+
"kill": "fuser -k 5000/tcp",
10+
"build": "tsc -b --noCheck && vite build",
11+
"lint": "eslint .",
12+
"optimize": "vite optimize",
13+
"preview": "vite preview",
14+
"build:pages": "bash ./build-for-gh-pages.sh",
15+
"predeploy": "npm run build:pages",
16+
"deploy": "gh-pages -d dist"
17+
},
1818
"dependencies": {
1919
"@github/spark": "^0.0.1",
2020
"@heroicons/react": "^2.2.0",

src/main-github-pages.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { createRoot } from 'react-dom/client'
33
import App from './App.tsx'
44
import "./main.css"
55
import "./index.css"
6+
// @github/spark/spark import is excluded and handled externally
67

78
createRoot(document.getElementById('root')!).render(
89
<App />

vite.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export default defineConfig({
3434
input: {
3535
main: resolve(__dirname, 'index.html'),
3636
},
37+
external: ['@github/spark/spark']
3738
}
3839
},
3940
resolve: {

0 commit comments

Comments
 (0)