Code Monkey home page Code Monkey logo

Comments (17)

guybedford avatar guybedford commented on August 20, 2024 1

@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.

guybedford avatar guybedford commented on August 20, 2024

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.

guybedford avatar guybedford commented on August 20, 2024

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.

zifeo avatar zifeo commented on August 20, 2024

@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.

iulian-birlica avatar iulian-birlica commented on August 20, 2024

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.

zifeo avatar zifeo commented on August 20, 2024

@iulian-birlica Thanks for letting us know.

@guybedford I can confirm same issue happens with latest version.

from jco.

guybedford avatar guybedford commented on August 20, 2024

@zifeo if we replace the .d.ts imports with .js imports will that work here?

from jco.

zifeo avatar zifeo commented on August 20, 2024

@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 of import 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.

guybedford avatar guybedford commented on August 20, 2024

@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.

zifeo avatar zifeo commented on August 20, 2024

@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.

guybedford avatar guybedford commented on August 20, 2024

@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.

zifeo avatar zifeo commented on August 20, 2024

@guybedford sorry, the PR got merged, can you retry now? I restored the branch :)

from jco.

guybedford avatar guybedford commented on August 20, 2024

@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.

zifeo avatar zifeo commented on August 20, 2024

@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.

guybedford avatar guybedford commented on August 20, 2024

Thanks again for the report here. I believe the cases here were fixed, but please reopen if we're still missing anything.

from jco.

zifeo avatar zifeo commented on August 20, 2024

@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.

guybedford avatar guybedford commented on August 20, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.