Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compute-baseline: incomplete import statements? #967

Open
tidoust opened this issue Apr 25, 2024 · 5 comments · Fixed by #1027
Open

compute-baseline: incomplete import statements? #967

tidoust opened this issue Apr 25, 2024 · 5 comments · Fixed by #1027
Assignees
Labels
bug Something isn't working

Comments

@tidoust
Copy link
Member

tidoust commented Apr 25, 2024

The NPM compute-baseline package does not work on my machine. Node.js complains about import statements with ERR_MODULE_NOT_FOUND errors. As far as I can tell, that's because the import statements in the package do not specify the filename extensions whereas that's mandatory. Also, there's an attempt to import a directory, which is not supported either.

@foolip foolip added the bug Something isn't working label Apr 25, 2024
@ddbeck
Copy link
Collaborator

ddbeck commented Apr 26, 2024

This is a consequence of using tsx to run everything here (and elsewhere I've used this code)—I never see what it looks like as a plain Node.js import. Oops!

I think the steps to fix this are:

  • Add .js extensions to all the imports
  • Change moduleResolution to "NodeNext" (maybe, need to test this)

@foolip
Copy link
Collaborator

foolip commented May 6, 2024

@tidoust can you check if v0.8.1 works for you?

@tidoust
Copy link
Member Author

tidoust commented May 6, 2024

v0.8.1 is web-features, not compute-baseline, right?

Testing compute-baseline by creating a dependency on a local folder with the latest version of the code in the web-features repository, I still have an import problem:

TypeError [ERR_IMPORT_ASSERTION_TYPE_MISSING]: Module "[full path redacted]/@mdn/browser-compat-data/data.json" needs an import attribute of type "json"

That's triggered by import bcd from "@mdn/browser-compat-data" statements such as:
https://github.com/web-platform-dx/web-features/blob/main/packages/compute-baseline/src/browser-compat-data/browser.ts#L1C1-L5C35

These import statements need something like with { type: 'json' } (well, or assert { type: 'json'} depending on the runtime version).

@ddbeck
Copy link
Collaborator

ddbeck commented May 6, 2024

Opened #1051 to fix the BCD import.

@ddbeck ddbeck reopened this May 6, 2024
@foolip
Copy link
Collaborator

foolip commented May 6, 2024

v0.8.1 is web-features, not compute-baseline, right?

Right... I got myself confused because I saw the hopeful fix for this in the list of changes for web-features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants