Comments (5)
This works in Deno Deploy if you use application/javascript
. So the example you just linked to does actually work in Deploy.
However dynamically importing a typescript class won't work currently, because in Deploy the typescript compiler isn't available at run-time.
from deno.
ahh, thank you. So i just need to transpile it first in theory? Is their any plan to support Deno Deploy typescript compiling at run time?
from deno.
What would be the best way to transpile at runtime? esbuild wasm? Or is there something else?
from deno.
I thought a bit of my code might be useful. This is what works locally, but not in Deno Deploy:
const fileContents = await toText(file.Contents);
const enc = base64.encodeBase64(fileContents);
const apiUrl = `data:application/typescript;base64,${enc}`;
const apiModule = await import(apiUrl);
const api = apiModule.default;
from deno.
Alright, i was able to get this working with esbuild.
I imported the WASM module:
import * as esbuild from 'https://deno.land/x/[email protected]/wasm.js';
Then, due to issues with using workers on deno deploy, had to add a call to:
await esbuild
.initialize({
worker: false,
})
Then, i was able to update my code to use transpiled TS and a javascript data url:
const fileContents = await toText(file.Contents);
const result = await esbuild.transform(fileContents, { loader: 'ts' });
const enc = base64.encodeBase64(result.code);
const apiUrl = `data:application/javascript;base64,${enc}`;
const apiModule = await import(apiUrl);
const api = apiModule.default
from deno.
Related Issues (20)
- JUnit reporter: Output XML doesn't contain any details regarding failures on test "step"s HOT 2
- `js_unit_test::{read_text_file_test, websocket_test}` are flaky
- Deno compile - Precompile Wasm HOT 3
- Bug: tailwindcss v4 alpha errors on import
- Bug: Fast check cannot infer type from this export HOT 1
- npm-compat: ts-results issues HOT 3
- Deno.errors.NotFound incomplete type (and maybe others)
- [regression-1.41.2] error: 'import', and 'export' cannot be used outside of module code HOT 11
- "worker_threads is not handling "threadId" correctly
- Consider unstable flag to make cjs files be treated as esm HOT 6
- `deno publish` failed to resolve types from import in workspace HOT 1
- node:http server doesn't handle read errors HOT 3
- I hope compiling to native binary was added for Deno. HOT 1
- `deno compile` custom binaries
- GPUDevice: uncapturederror event seems not implemented HOT 1
- Compiled binary support for typescript HOT 2
- Unexpected publish errors HOT 2
- `error: invalid UTF-8 was detected in one or more arguments` happens for environment variables but not arguments
- Deno run pauses at end of script after running command HOT 6
- Deno too aggressively ignores folders named vendor
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 deno.