<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 29, 2022 at 3:54 PM Yadd <<a href="mailto:yadd@debian.org">yadd@debian.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi all,<br>
<br>
some packages, especially those from Sindre Sorhus, changed both:<br>
  * language from commonjs to ECMA only ("type": "module")<br>
  * API:<br>
      const foo = require("foo"); // gives also foo.bar<br>
    becomes:<br>
      import { foo, fooBar } from "foo";<br>
<br>
I build new node-find-up, node-chalk (exp) and node-globy (exp) <br>
following this:<br>
  * build commonjs file using rollup<br>
  * add an index.cjs file which keeps old and new API<br>
  * modify package.json to replace "type=module" by an extended "exports"<br>
<br>
Since new module is "type=module" then we are sure that no reverse <br>
dependency will call it using "require" but wanted new behavior. This <br>
permits to have a transition: node-find-up for example seems usable for <br>
any reverse dependency. Only package which are built from ECMA but <br>
wanted old version could have their build broken.<br></blockquote><div><br></div><div>Awesome ! The author of these packages is pushing too hard to use es modules...</div></div></div>