sheerlox / import-from-esm Goto Github PK
View Code? Open in Web Editor NEWAlmost drop-in "import-from" replacement that supports loading both ESM & CJS modules
License: MIT License
Almost drop-in "import-from" replacement that supports loading both ESM & CJS modules
License: MIT License
npm ERR! code 2
npm ERR! path /home/rowlands/git/vite-plugin-twig-drupal/node_modules/import-from-esm
npm ERR! command failed
npm ERR! command sh -c cd tests/fixture/nested/ && npm ci
npm ERR! sh: 1: cd: can't cd to tests/fixture/nested/
Add the ability to import an NPM package that contains an index.json
file or has a main
field pointing to a JSON file.
Fuzz testing takes a lot of time to run, and decreases the feedback loop of the test workflow running on PRs significantly.
Running it as a separate workflow (e.g. on main
commits) would also allow running it for longer, improving its benefits.
Working on: https://github.com/straw-hat-team/nodejs-monorepo/pull/119/files
I had to do the following:
// @ts-expect-error
import importFrom from "import-from-esm";
Since for some reason the type system is confused:
yarn build
src/openapi-web-sdk-generator.ts:2:8 - error TS1192: Module '"/Users/ubi/Developer/github.com/straw-hat-team/nodejs-monorepo/.yarn/cache/import-from-esm-npm-1.2.1-19132a3a23-17275e7d51.zip/node_modules/import-from-esm/index"' has no default export.
2 import importFrom from "import-from-esm";
~~~~~~~~~~
Found 1 error in src/openapi-web-sdk-generator.ts:2
Any thoughts?
A good way to test import-from-esm
alignment with require
's specs would be to validate its outcome against require
's outcome using the same parameters (only ignoring ERR_REQUIRED_ESM
errors from require
).
This library is intended to be an almost drop-in replacement of sindresorhus/import-from (from which it is forked) that supports loading ESM & CJS modules like require()
does.
Since import-from
uses createRequire()
under the hood, it throws the ERR_REQUIRE_ESM
error when trying to import a pure ESM module.
The Node.js modules documentation states:
Due to the synchronous nature of require(), it is not possible to use it to load ECMAScript module files. Attempting to do so will throw a ERR_REQUIRE_ESM error. Use import() instead.
Switching from require()
to a dynamic import()
has a lot of implications, but these are the ones I encountered issues with:
import()
is asynchronous,This library will provide a module loading strategy as close to CJS' as possible, as well as work around the above issues (except the first one, nothing can be done about this).
It's only breaking change from import-from
should be adding an await
in front of the importFrom()
calls, and a .default
when importing default exports.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These problems occurred while renovating this repository. View logs.
These updates await pending status checks. To force their creation now, click the checkbox below.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.
.github/workflows/codeql.yml
step-security/harden-runner v2.6.1@eb238b55efaa70779f274895e782ed17c84f2895
actions/checkout v4.1.1@b4ffde65f46336ab88eb53be808477a3936bae11
github/codeql-action v3.22.11@b374143c1149a9115d881581d29b8390bbcbb59c
github/codeql-action v3.22.11@b374143c1149a9115d881581d29b8390bbcbb59c
github/codeql-action v3.22.11@b374143c1149a9115d881581d29b8390bbcbb59c
.github/workflows/release.yml
step-security/harden-runner v2.6.1@eb238b55efaa70779f274895e782ed17c84f2895
actions/checkout v4@b4ffde65f46336ab88eb53be808477a3936bae11
actions/setup-node v4@8f152de45cc393bb48ce5d89d36b731f54556e65
.github/workflows/scorecard.yml
step-security/harden-runner v2.6.1@eb238b55efaa70779f274895e782ed17c84f2895
actions/checkout v4.1.1@b4ffde65f46336ab88eb53be808477a3936bae11
ossf/scorecard-action v2.3.1@0864cf19026789058feabb7e87baa5f140aac736
actions/upload-artifact v4.0.0@c7d193f32edcb7bfad88892161225aeda64e9392
github/codeql-action v3.22.11@b374143c1149a9115d881581d29b8390bbcbb59c
.github/workflows/test.yml
insurgent-lab/is-in-pr-action v0.1.5@3e01b38aa0d2a0e51bbc84540300303ec850e80d
step-security/harden-runner v2.6.1@eb238b55efaa70779f274895e782ed17c84f2895
actions/checkout v4@b4ffde65f46336ab88eb53be808477a3936bae11
actions/setup-node v4@8f152de45cc393bb48ce5d89d36b731f54556e65
actions/upload-artifact v4@c7d193f32edcb7bfad88892161225aeda64e9392
step-security/harden-runner v2.6.1@eb238b55efaa70779f274895e782ed17c84f2895
actions/checkout v4@b4ffde65f46336ab88eb53be808477a3936bae11
actions/download-artifact v4@7a1cd3216ca9260cd8022db641d960b1db4d1be4
SonarSource/sonarcloud-github-action v2.1.1@49e6cd3b187936a73b8280d59ffd9da69df63ec9
package.json
debug ^4.3.4
import-meta-resolve ^4.0.0
@fast-check/ava 1.2.0
@insurgent/export-map-test 1.0.1
@insurgent/json-index-test 2.0.0
@insurgent/json-main-test 2.0.0
@insurgentlab/conventional-changelog-preset 7.0.0
@semantic-release/changelog 6.0.3
@semantic-release/git 10.0.1
@types/debug 4.1.12
ava 5.3.1
c8 8.0.1
cross-env 7.0.3
knip 3.8.1
semantic-release 22.0.12
tsd 0.29.0
xo 0.56.0
node >=16.20
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.