Git Product home page Git Product logo

Comments (4)

ovidiuch avatar ovidiuch commented on June 16, 2024 2

Thanks @ThaisRobba and @predragnikolic for reporting this and providing context!

Fixed it in #1564 and upgraded the CI jobs from Node 16 & 18 to Node 18 & 20.

Didn't supress the ExperimentalWarning because I want us to stay aware that "Custom ESM Loaders is an experimental feature and might change at any time". In the meantime I subscribed to TypeStrong/ts-node#1997 so if a better solution for using ts-node comes along we can switch to that.

from react-cosmos.

predragnikolic avatar predragnikolic commented on June 16, 2024

I have experienced the same issue.

λ  react-cosmos main ✗ node -v
v20.5.0
λ  react-cosmos main ✗ yarn -v
1.22.11

I tired made the following change in package.json and it started working:

- "build": "ts-node --esm ./scripts/build.ts"
+ "build": "node --loader ts-node/esm ./scripts/build.ts"

Does this work for you?

from react-cosmos.

predragnikolic avatar predragnikolic commented on June 16, 2024

Not an expert,
but base on the docs https://github.com/TypeStrong/ts-node#commonjs-vs-native-ecmascript-modules
I would say ts-node --esm, ts-node-esm and node --loader ts-node/esm can be used interchangeably, but I am not sure.

But on my setup, only node --loader ts-node/esm will work in the build script.
the other two will throw the ERR_UNKNOWN_FILE_EXTENSION error.

I tried to see what config does the ts-node command use, and here is the output of npx ts-node --showConfig

λ  react-cosmos main ✗ npx ts-node --showConfig
{
  "ts-node": {
    "cwd": "/home/predragnikolic/Documents/sandbox/react-cosmos",
    "projectSearchDir": "/home/predragnikolic/Documents/sandbox/react-cosmos",
    "project": "/home/predragnikolic/Documents/sandbox/react-cosmos/tsconfig.json"
  },
  "compilerOptions": {
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "jsx": "react",
    "moduleResolution": "node10",
    "newLine": "lf",
    "noEmit": false,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noUnusedLocals": true,
    "skipLibCheck": true,
    "strict": true,
    "target": "es2022",
    "module": "es2022",
    "sourceMap": true,
    "inlineSourceMap": false,
    "inlineSources": true,
    "declaration": false,
    "outDir": "./.ts-node"
  }
}

notice "moduleResolution": "node10", this line is not the same as the original line in tsconfig.json.

from react-cosmos.

predragnikolic avatar predragnikolic commented on June 16, 2024

Found the related issue on ts-node TypeStrong/ts-node#1997

from react-cosmos.

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.