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

ExperimentalWarning: Import assertions are not a stable feature of the JavaScript language #236

Closed
1 task done
zaripych opened this issue May 4, 2023 · 4 comments · Fixed by #300
Closed
1 task done
Labels
bug Something isn't working outdated

Comments

@zaripych
Copy link

zaripych commented May 4, 2023

Bug description

When I run tsx code.ts I get following output:

➜  esm-loader-warning-repro pnpm tsx code.ts
(node:76711) ExperimentalWarning: Import assertions are not a stable feature of the JavaScript language. Avoid relying on their current behavior and syntax as those might change in a future version of Node.js.
(Use `node --trace-warnings ...` to show where the warning was created)
Hello esm-loader-warning-repro!

I expected:

Hello esm-loader-warning-repro!

I've noticed that we already suppress some warnings in here

Should we suppress this type of warning as well?

Reproduction

I have "type": "module" in my package.json:

{
  "name": "esm-loader-warning-repro",
  "version": "1.0.0",
  "type": "module",
  "dependencies": {
    "tsx": "^3.12.7"
  }
}

code.ts has following content:

import pack from "./package.json";

console.log(`Hello ${pack.name}!`);

I'm using Node 18:

➜  esm-loader-warning-repro pnpm tsx --version
tsx v3.12.7
node v18.16.0

Environment

System:
    OS: macOS 13.2.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 24.08 GB / 64.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.16.0/bin/yarn
    npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm
  npmPackages:
    tsx: ^3.12.7 => 3.12.7

Can you work on a fix?

  • I’m interested in opening a pull request to address this issue.
@zaripych zaripych added bug Something isn't working pending triage labels May 4, 2023
@privatenumber
Copy link
Owner

IIRC they have a new way of making import assertions. Could we use that instead on newer versions of Node.js?

@zaripych
Copy link
Author

zaripych commented May 5, 2023

In my example above, I do not do any assertions explicitly, it's the latest version of the esm-loader that causes the warning.

image

If we can do something to make the warning go away in the esm-loader then we can take that path. I'm not very familiar with loader API, but ignoring a warning by adding a string to an array seems like an easy fix with low risk.

@ArnaudBarre
Copy link

I've been annoyed by this warning so I tried to build a slim tsx version. For the JSON import I provided a loader to that there is not warning not usage of experimental API:

@privatenumber privatenumber changed the title Experimental Features warnings ExperimentalWarning: Import assertions are not a stable feature of the JavaScript language Sep 2, 2023
@privatenumber
Copy link
Owner

The warning was added in nodejs/node#46901 and motivated by nodejs/node#46830 but there is currently no successor to the assert syntax.

@privatenumber privatenumber mentioned this issue Sep 2, 2023
21 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working outdated
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants