Git Product home page Git Product logo

Comments (7)

Andarist avatar Andarist commented on September 27, 2024 1

If you were relying on tsc for dual emit then it might be the easiest to switch to using tshy. If you prefer to handroll the solution then I'd recommend switching to .ts files. I've seen you have post-processing step to fixup extensions and stuff - that step could be reused. It feels that if you just tweak its logic a little bit to handle a different set of files and do a slightly different fixup then it should work. Note that I didn't take too deep into your current setup so what I'm saying is not a guarantee but rather a conclusion drawn solely on a first impression of a very tiny slice of your repo ;p

from typescript.

Andarist avatar Andarist commented on September 27, 2024

bisects to #59479

from typescript.

Andarist avatar Andarist commented on September 27, 2024

So it seems that before this PR it would ignore the fact that your files are authored using .mts and it would allow you to compile that to a commonjs module. With the new version the extension is always taken into consideration, even with "moduleResolution": "node10".

We can trace back this work to #57896 and #58825 . They mention that from now on extensions should be considered in more module modes but they are not as explicit when it comes to what does it mean for moduleResolution modes.

This is a one-line change to fix your issue but the changed code is also almost explicit when it comes to applying the new logic for extensions regardless of moduleResolution... so I think it's best to ping @andrewbranch and defer to his opinion about this.

Minimal repro case:

// @moduleResolution: node10
// @module: commonjs

// @filename: index.mts
export const foo = ''

from typescript.

andrewbranch avatar andrewbranch commented on September 27, 2024

Yes, this is working as intended. Compiling .mts files to CommonJS-containing .mjs files was not something we ever intended to support—the fact that it ever worked was a bug / unintentional side effect of other work.

from typescript.

MartinJohns avatar MartinJohns commented on September 27, 2024

Related: https://devblogs.microsoft.com/typescript/announcing-typescript-5-6/#respecting-file-extensions-and-package.json-from-within-node_modules

from typescript.

typescript-bot avatar typescript-bot commented on September 27, 2024

This issue has been marked as "Working as Intended" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

from typescript.

SBoudrias avatar SBoudrias commented on September 27, 2024

Thanks for the answer! I'll review how I dual ship then.

It might be good to document cases where tsc ignore settings. I combed through the documentation first and this behavior didn't appear obvious to me.

from typescript.

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.