[π]Netlify deployment fails with Bun: `SyntaxError: Unexpected token ':'` during "Edge Functions bundling"
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 22.1k
- Forks
- 1.4k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 52
Description
Which component is affected?
Qwik Runtime
Describe the bug
Bug Description
Hello,
I am trying to deploy my Qwik project to Netlify using the Netlify Edge adapter. When I run the deployment command (bun run deploy), the build fails on Netlify with an internal error during the "Edge Functions bundling" step.
The reported error is a SyntaxError: Unexpected token ':', which seems to originate from the Edge Functions manifest validation process by Netlify's bundler (@netlify/edge-bundler), specifically when using ajv for schema validation.
Reproduction
Steps to reproduce the issue are as follows:
- Create a Qwik project with the
netlify-edgeadapter. - Use
bunas the package manager and script runner. - Configure the project for Netlify deployment.
- Run the deployment command (e.g.,
npm run buildor an equivalent command). - The build fails on Netlify during the bundling process.
Expected behavior
The project should build and deploy successfully to Netlify without any errors during the 'Edge Functions bundling' step.
Logs and Screenshots
Here is the full error returned by the Netlify build terminal:
Internal error during "Edge Functions bundling"
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Error message
SyntaxError: Unexpected token ':'
Error location
During Edge Functions bundling
at new Function (<anonymous>)
at Ajv.compileSchema (/home/tom/Documents/Dental_Qwik/node_modules/@netlify/build/node_modules/@netlify/edge-bundler/node_modules/ajv/dist/compile/index.js:89:30)
at Ajv._compileSchemaEnv (/home/tom/Documents/Dental_Qwik/node_modules/@netlify/build/node_modules/@netlify/edge-bundler/node_modules/ajv/dist/core.js:473:37)
at Ajv.compile (/home/tom/Documents/Dental_Qwik/node_modules/@netlify/build/node_modules/@netlify/edge-bundler/node_modules/ajv/dist/core.js:160:38)
at initializeValidator (file:///home/tom/Documents/Dental_Qwik/node_modules/@netlify/build/node_modules/@netlify/edge-bundler/dist/node/validation/manifest/index.js:17:33)
at validateManifest (file:///home/tom/Documents/Dental_Qwik/node_modules/@netlify/build/node_modules/@netlify/edge-bundler/dist/node/validation/manifest/index.js:24:22)
at validateEdgeFunctionsManifest (file:///home/tom/Documents/Dental_Qwik/node_modules/@netlify/build/lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js:5:9)
at coreStep (file:///home/tom/Documents/Dental_Qwik/node_modules/@netlify/build/lib/plugins_core/edge_functions/index.js:48:15)
at async fireCoreStep (file:///home/tom/Documents/Dental_Qwik/node_modules/@netlify/build/lib/steps/core_step.js:9:98)
at async tFireStep (file:///home/tom/Documents/Dental_Qwik/node_modules/@netlify/build/lib/time/main.js:18:63)
Resolved config
build:
command: npm run build
commandOrigin: config
publish: /home/tom/Documents/Dental_Qwik/dist
publishOrigin: config
headers:
- for: /assets/*
values:
Cache-Control: public, max-age=31536000, s-maxage=31536000, immutable
- for: /build/*
values:
Cache-Control: public, max-age=31536000, s-maxage=31536000, immutable
Waiting for the debugger to disconnect...
error: script "deploy" exited with code 4
System Information
- OS: Arch Linux
- Qwik Version:
latest - Qwik City Version:
latest - Bun Version:
latest - Qwik Adapter: Netlify Edge
Additional Context
Here is the content of my vite.config.ts file. It's fairly standard, but I'm providing it for context.
/**
* This is the base config for vite.
* When building, the adapter config is used which loads this file and extends it.
*/
import { qwikVite } from "@builder.io/qwik/optimizer";
import { qwikCity } from "@builder.io/qwik-city/vite";
import tailwindcss from "@tailwindcss/vite";
import { vanillaExtractPlugin } from "@vanilla-extract/vite-plugin";
import { defineConfig, type UserConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import pkg from "./package.json";
type PkgDep = Record<string, string>;
const { dependencies = {}, devDependencies = {} } = pkg as any as {
dependencies: PkgDep;
devDependencies: PkgDep;
[key: string]: unknown;
};
errorOnDuplicatesPkgDeps(devDependencies, dependencies);
/**
* Note that Vite normally starts from `index.html` but the qwikCity plugin makes start at `src/entry.ssr.tsx` instead.
*/
export default defineConfig(({ command, mode }): UserConfig => {
return {
plugins: [
qwikCity(),
vanillaExtractPlugin({
identifiers: mode === "production" ? "short" : "debug",
}),
qwikVite(),
tsconfigPaths({ root: "." }),
tailwindcss(),
],
// This tells Vite which dependencies to pre-build in dev mode.
optimizeDeps: {
// Put problematic deps that break bundling here, mostly those with binaries.
// For example ['better-sqlite3'] if you use that in server functions.
exclude: [],
},
/**
* This is an advanced setting. It improves the bundling of your server code. To use it, make sure you understand when your consumed packages are dependencies or dev dependencies. (otherwise things will break in production)
*/
// ssr:
// command === "build" && mode === "production"
// ? {
// // All dev dependencies should be bundled in the server build
// noExternal: Object.keys(devDependencies),
// // Anything marked as a dependency will not be bundled
// // These should only be production binary deps (including deps of deps), CLI deps, and their module graph
// // If a dep-of-dep needs to be external, add it here
// // For example, if something uses `bcrypt` but you don't have it as a dep, you can write
// // external: [...Object.keys(dependencies), 'bcrypt']
// external: Object.keys(dependencies),
// }
// : undefined,
server: {
headers: {
// Don't cache the server response in dev mode
"Cache-Control": "public, max-age=0",
},
},
preview: {
headers: {
// Do cache the server response in preview (non-adapter production build)
"Cache-Control": "public, max-age=600",
},
},
};
});
// *** utils ***
/**
* Function to identify duplicate dependencies and throw an error
* @param {Object} devDependencies - List of development dependencies
* @param {Object} dependencies - List of production dependencies
*/
function errorOnDuplicatesPkgDeps(
devDependencies: PkgDep,
dependencies: PkgDep,
) {
let msg = "";
// Create an array 'duplicateDeps' by filtering devDependencies.
// If a dependency also exists in dependencies, it is considered a duplicate.
const duplicateDeps = Object.keys(devDependencies).filter(
(dep) => dependencies[dep],
);
// include any known qwik packages
const qwikPkg = Object.keys(dependencies).filter((value) =>
/qwik/i.test(value),
);
// any errors for missing "qwik-city-plan"
// [PLUGIN_ERROR]: Invalid module "@qwik-city-plan" is not a valid package
msg = `Move qwik packages ${qwikPkg.join(", ")} to devDependencies`;
if (qwikPkg.length > 0) {
throw new Error(msg);
}
// Format the error message with the duplicates list.
// The `join` function is used to represent the elements of the 'duplicateDeps' array as a comma-separated string.
msg = `
Warning: The dependency "${duplicateDeps.join(", ")}" is listed in both "devDependencies" and "dependencies".
Please move the duplicated dependencies to "devDependencies" only and remove it from "dependencies"
`;
// Throw an error with the constructed message.
if (duplicateDeps.length > 0) {
throw new Error(msg);
}
}
It seems there might be an incompatibility between the output generated by the Qwik build (likely the server functions manifest) and what the Netlify bundler expects.
Thanks for your help.
Reproduction
Steps to reproduce
bun run deploy
System Info
Latest
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up β it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with vite.config.ts and reproduce the failure using bun run deploy, focusing on the Netlify Edge Functions bundling and manifest-validation steps shown in the log. Compare the generated output with the reported bundler failure; done means the project builds and deploys successfully without the Unexpected token ':' error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bun, typescript, vite
- Domain
- backend, cloud, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100