Giter VIP home page Giter VIP logo

is-esm's Introduction

is-esm

This package tells you if an npm module uses ECMAScript modules or not.

Why do I need to know?

ECMAScript modules are statically analyzable. This helps bundlers and JavaScript optimizers to get rid of the unused exports and ultimately make your bundles smaller.

You can read more about this here.

How to use it?

To use is-esm:

$ npx is-esm @angular/core 8.0.0
$ โœ” Yes
$ npx is-esm moment
$ โœ– No

License

MIT

is-esm's People

Contributors

dependabot[bot] avatar mgechev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

is-esm's Issues

Unable to detect the module format for yargs

Hello

My initial attempt was to try npx is-esm yargs. It was my first reflex because I knew that this library had made the transition to ESM as detailed in their blog post from 2020: https://yargs.js.org/2020/09/07/yargs-16.html

Unfortunately it failed with a Unable to detect the module format. As the caught error is silenced, I don't know yet what's happening.

By inspecting the package.json of yargs, we can get a few clues that ESM is supported because there's an exports object with definition pointing to .mjs file. https://github.com/yargs/yargs/blob/main/package.json

So maybe is-esm could fallback on this kind of heuristics in case the rollup method does not work as intended?

Thanks!

False-negative when using npm v7

It looks like at the moment, npm v7 returns "No" in any case.

This is an test run, first on node 12 / npm 6; then node 12 / npm 7, and then back on node 12 / npm 6:

โžœ  nvm use 12.20.0
Now using node v12.20.0 (npm v6.14.13)
โžœ  npx is-esm @angular/core
npx: installed 58 in 2.737s
โœ” Yes


โžœ  npm install -g npm@7
โ€ฆ
+ [email protected]
added 62 packages from 25 contributors, removed 242 packages and updated 193 packages in 4.412s
โžœ  nvm use 12.20.0
Now using node v12.20.0 (npm v7.18.1)
โžœ  npx is-esm @angular/core
โš  No


โžœ  npm install -g npm@6

removed 62 packages, changed 99 packages, and audited 436 packages in 2s

3 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
โžœ  nvm use 12
Now using node v12.20.0 (npm v6.14.13)
โžœ  npx is-esm @angular/core
npx: installed 58 in 2.618s
โœ” Yes

I tried to debug it, but so far found that running installCommand doesn't not create node_modules in the temporary directory.

With npm@6 the stdout of installModules() is:

added 2 packages from 2 contributors and audited 2 packages in 0.866s
found 0 vulnerabilities

But npm@7 it is:

up to date, audited 7 packages in 925ms

found 0 vulnerabilities

I think it's related to the --prefix, as running the same command in the temp dir without it works fine.

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.