Comments (6)
Howdy,
It looks to me like @hanazuki/node-jsonnet
depends on running in a nodejs environment and expects nodejs built-in packages to exist such as fs and path. js-compute-runtime is not based on nodejs and does not have the same built-in packages as nodejs, which is why @hanazuki/node-jsonnet
does not work
from js-compute-runtime.
Thank you for your reply and time!
the error also suggests that we can specify this "platform: 'node'"
somewhere,
does this suggestion is provided by fastly-compute-runtime
or honojs
?
and once again Thank you so much for your time!! 🙏🏼
from js-compute-runtime.
Unfortunately setting "platform: 'node'"
will not solve the issue as that is telling the bundler that your target environment is node
and so has the node built-ins such as FS and path, but your target environment is not node
and does not have those built-ins
from js-compute-runtime.
@JakeChampion That's unfortunate, but is there any way I can read files in js-compute-runtime from the src
directory like JSON
or yaml
files so that I can find some alternative to @hanazuki/node-jsonnet
from js-compute-runtime.
Yes, you can include the file during build/compile time using includeBytes
and then convert to a string and then parse using JSON/yaml.
Something like this:
/// <reference types="@fastly/js-compute" />
import { includeBytes } from "fastly:experimental";
const decoder = new TextDecoder();
const config = JSON.parse(decoder.decode(includeBytes('src/config.json')));
async function app() {
return new Response("hello");
}
addEventListener("fetch", event => event.respondWith(app(event)));
An alternative would be to store the JSON/yaml files in a KV Store and then use the JSON method when reading them:
/// <reference types="@fastly/js-compute" />
import { KVStore } from "fastly:kv-store";
async function app(event) {
const files = new KVStore('files')
const entry = await files.get('config')
const config = await entry.json()
return new Response("hello")
}
addEventListener("fetch", (event) => event.respondWith(app(event)))
from js-compute-runtime.
This looks perfect!!
Once again, thank you for your time!
from js-compute-runtime.
Related Issues (20)
- No access to tls.client HOT 1
- Support for Yarn Plug'n'Play
- feature-request: support for SubtleCrypto encrypt and decrypt for AES-CBC and AES-GCM
- Feature request: SubtleCrypto support for RSA-PSS, ECDSA, ED25519, pkcs8 and spki HOT 3
- bug: namespace module imports break jest testing HOT 10
- ClientInfo type doesn't contain the new fields from v3 HOT 1
- Feature Request: Form factor and client browser detection (UserAgent)
- Add error.cause property to errors which originate from an underlying host error
- package.json exports order change breaks fastly compute build HOT 4
- Incorrect implementation for ECDSA verification
- Raise an error during wizening for async functions given to addEventListener
- Record pbl use in metadata
- Qwik City on Fastly HOT 2
- ":" character in filenames will make the Typescript starter-kit fail under Windows. HOT 1
- Requested backend named '' does not exist HOT 3
- .node files in fastly
- Load Wasm files in Javascript HOT 1
- Response.prototype.text() returning empty string in some cases HOT 1
- Support top-level await HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js-compute-runtime.