j4
j4
Explore posts from servers
CDCloudflare Developers
Created by j4 on 2/13/2025 in #workers-help
How to import js file using a relative import?
I've been banging my head against the wall, trying to figure out how to get this code to work. This is the built version, so manifest_file could be something else during dev. wrangler deploy always crashes on this, saying Uncaught Error: No such module "manifest.js". the index.js and manifest.js files are in the same directory - as a result of a vite build step. This works fine in the bun and deno runtimes, but having issues with wrangler/cloudflare.
const manifest_file = "./manifest.js";
const { manifest } = await import(manifest_file);
const manifest_file = "./manifest.js";
const { manifest } = await import(manifest_file);
1 replies
DDeno
Created by j4 on 10/26/2024 in #help
Vite plugin's global variables are `undefined` when using Deno
Anyone run across this before? Running Deno 2 and Vite 6beta. I built a third-party Vite plugin, and now I'm testing it in a "native" Deno project (deno.json, not package.json, etc). However, all of the packages and dependencies are from npm. My Vite plugin defines a global like so.
...
return {
define: {
'XINK_VITE_MODE': JSON.stringify(mode)
}
}
...
...
return {
define: {
'XINK_VITE_MODE': JSON.stringify(mode)
}
}
...
In another part of my plugin package's code, not within the vite plugin definition itself, I grab the value during runtime, but it's logging undefined. This works fine when using Bun. I also tried doing globalThis.XINK_VITE_MODE as well, since Vite's intellisense said it's supposed be available on window during dev.
export const initRouter = async () => {
const mode = XINK_VITE_MODE
console.log('Vite mode is:', mode)
...
}
export const initRouter = async () => {
const mode = XINK_VITE_MODE
console.log('Vite mode is:', mode)
...
}
2 replies
DDeno
Created by j4 on 12/30/2022 in #help
Getting error `Unrecognized algorithm name` on `crypto.subtle.importKey()`
I can't figure this one out. I've done some searching and found a list of supported algos at https://deno.land/[email protected]/crypto/mod.ts See anything I'm doing wrong? I tried it without the hash as well. Here's a snippet:
/* supabase edge function */
import { crypto } from 'https://deno.land/[email protected]/crypto/mod.ts'

const cryptokey = await crypto.subtle.importKey('spki', encoded_plain_key, 'SHA-512', false, ['sign'])
/* supabase edge function */
import { crypto } from 'https://deno.land/[email protected]/crypto/mod.ts'

const cryptokey = await crypto.subtle.importKey('spki', encoded_plain_key, 'SHA-512', false, ['sign'])
4 replies