GithubHelp home page GithubHelp logo

Comments (6)

sindresorhus avatar sindresorhus commented on May 28, 2024 1

I plan to move directly to ESM without any CommonJS support. I'm just waiting for TypeScript 4.7 (which will have full ESM support), so I don't have to deal with too many TS support issues.

The API will be two named exports: delete and deleteSync.

It's probably easier if I do the migration myself as there's a lot of details to get right.

https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

from del.

sindresorhus avatar sindresorhus commented on May 28, 2024 1

Does that mean you'd like to convert this library to TypeScript and compile both CommonJS and ESM?

No. The TS mention is about TS not being able to handle ESM until TS 4.7.

from del.

frank-dspeed avatar frank-dspeed commented on May 28, 2024

Review: #140 it demonstrates why i want the api change as there is no other good upgrade path at last i do not see it.

from del.

frank-dspeed avatar frank-dspeed commented on May 28, 2024

@sindresorhus i am specialist for the new ESM support in typescript 4.7 and got bad new for you and some good as long as you output a single entrypoint your package.json needs the following to be compatible to typescript moduleResolution node12 + nodenext

{
  "main": "name.js",
  "types": "name.js",
  "type": "module",
  "exports": "name.js"
}

note that you can use the .cjs and .mjs extensions with this example typescript 4.7 will then lookup: name.d.mts or name.d.cts
there is no fallback to index.d.ts!

{
  "type": "module",
  "exports": { 
    "node": { 
      "import": "./name.js",
      "types": "./name.js"
    },
    "import": "./name.js",
    "types": "./name.js"
  } 
}

the above example uses the object form and also droped types and main fild as they are not needed this will only work with moduleResolution: node12 nodenext so it is not backward compatible add main and types to stay typescript backward compatible also it shows that you need to add types for each nested level.

when you use a Object for exports a lot of edge conditions can apply this was the most basic version for a esm only module

also be aware that subPath Patterns are not supported by typescript as soon as you use them your on your own

when you want the object form you need to add a types fild to each alias and to the root alias this is WiP but the root level works and there is no option to choose the conditions that typescript will use

from del.

jonkoops avatar jonkoops commented on May 28, 2024

I plan to move directly to ESM without any CommonJS support. I'm just waiting for TypeScript 4.7 (which will have full ESM support), so I don't have to deal with too many TS support issues.

Does that mean you'd like to convert this library to TypeScript and compile both CommonJS and ESM?

from del.

jonkoops avatar jonkoops commented on May 28, 2024

I have an implementation ready for this issue under #143.

from del.

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.