Comments (17)
@zifeo thanks for following up on this - I finally see what you mean in that the relative type import from one typing file to another is wired up incorrectly. I've posted a dedicated issue for this specific relative type loading issue in #112 and will aim to post a fix soon.
from jco.
Thanks for the feedback here, can you share the example WIT and flags you were using to get the above output with 'core': typeof CoreExports
? Also make sure you are running the latest release of jco as well.
from jco.
Unfortunately, it seems TypeScript itself doesn't like the .d.ts
extension being explicit - see the CI error in #105:
1) Typescript compilation
TypeScript Compilation:
Error: test/output/flavorful/flavorful.d.ts(1,33): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './imports/testwasi.js' instead.
from jco.
@guybedford Thanks for looking into this. Wit can be found here and we are using jco 0.7.0 because we cannot support yet component version 3 in all hosts (waiting for Python support).
from jco.
I saw your issue because it was linked to mine. Python support for component version 3 happened in wasmtime-py, so you can now go on with development.
from jco.
@iulian-birlica Thanks for letting us know.
@guybedford I can confirm same issue happens with latest version.
from jco.
@zifeo if we replace the .d.ts
imports with .js
imports will that work here?
from jco.
@guybedford Here is the wit and use case: Repro & WIT files with:
cargo build -p typegraph_core --target wasm32-unknown-unknown -F wasm
wasm-tools component new target/wasm32-unknown-unknown/debug/typegraph_core.wasm -o target/debug/typegraph_core.wasm
jco transpile target/debug/typegraph_core.wasm -o typegraph/deno/gen --no-nodejs-compat --map "*=../src/imports.ts"
There is a few things looking weird:
- imports and exports seems inverted :
import type { RuntimeId } from '../imports/core';
instead of from the exports folder - the base imports does not consider the package name (component 3) but the file name are:
import type { RuntimeId } from "../imports/core";
instead ofimport type { RuntimeId } from "../exports/metatype-typegraph-core.d.ts";
- imports in Deno are URL so they require the extension: I suppose a
--deno
flag is required - for the
.d.ts
import, there is an official cookbook : https://deno.land/[email protected]/advanced/typescript/types
What do you advise here? We currently run a bash script to fix those points.
from jco.
@zifeo I think I agree with you that an explicit --deno-compat
flag would make sense here given there doesn't seem to be a supportable subset.
Are you interested in contributing to the project? Otherwise I will get to this one when I can.
from jco.
@guybedford let's see whether we can give it a try in the next days. How should the first element be handled "imports and exports seems inverted", is that expected or is there something we are not following for that?
from jco.
@zifeo I can take a look at the other issues from the case, but couldn't get the clone to work as the deps
branch does not seem to be there though?
from jco.
@guybedford sorry, the PR got merged, can you retry now? I restored the branch :)
from jco.
@zifeo just had a look and this is the WIT I get for jco wit target/debug/typegraph_core.wasm
:
package root:component
world root {
import metatype:typegraph/abi
export metatype:typegraph/core
export metatype:typegraph/runtimes
}
And here is the main generated TypeScript file:
import { ImportsAbi } from './imports/abi';
import { ExportsMetatypeTypegraphCore } from './exports/metatype-typegraph-core';
import { ExportsMetatypeTypegraphRuntimes } from './exports/metatype-typegraph-runtimes';
export const core: typeof ExportsMetatypeTypegraphCore;
export const runtimes: typeof ExportsMetatypeTypegraphRuntimes;
This matches correctly - core
and runtimes
are exported, while abi
is imported.
The file name does include the full name as well it seems.
Let me know if there's something I'm missing, otherwise I think it's just the Deno extension issue here then?
from jco.
@guybedford look at the file exports/metatype-typegraph-runtimes.d.ts
, there is a few imports with the following form '../imports/core'
which points at nothing. Can you reproduce that?
from jco.
Thanks again for the report here. I believe the cases here were fixed, but please reopen if we're still missing anything.
from jco.
@guybedford Sorry the late answer, the version 0.12.1 works better, thanks! There is a Deno incompatibility due to the file extension. A simple post processing is enough: .replace(/^(import .*)(?<!\.ts)\';$/, "$1.d.ts';")
. Can we keep this open till we have time to contribute or until there is a deno flag?
from jco.
@zifeo with #228, we now use the .js
extension in the type definitions. Do share if this helps this issue or not.
from jco.
Related Issues (20)
- How do I use `js-component-bindgen`? HOT 1
- Incorrect codegen for `wasi:http` resource `RequestOptions` HOT 2
- JCO serve error on composed component HOT 1
- Are TypeScript definitions generated by transpile supposed to include comments from the WIT file? HOT 2
- Validity of file descriptors in the context of the `SyncKit` worker HOT 3
- Unsupported URL wasi when running in Node.js HOT 2
- Transpile bindings for `u32` map to `number` in *.d.ts HOT 3
- Non-conformant exceptions should unwrap as traps HOT 2
- Jco transpile: implementation of wasi-nn for Web HOT 2
- Source phase imports output
- Performance
- JS/WIT Reference
- Lifting `list<borrow<res>>` during transpilation emits invalid code HOT 3
- Resource transferring seems not working with wasi-virt HOT 1
- Crash on startup with an out-of-memory error when environment variables are large HOT 3
- Provide wasm-tools APIs in the browser HOT 2
- `definedResourceTables` codegen generates invalid JS with `--instantiation async` HOT 1
- plain enums are generating complex typescript HOT 8
- Question: `jco types` generating namespaces instead of modules? HOT 3
- Better instantiation workflows HOT 1
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 jco.