Giter Club home page Giter Club logo

import-from-esm's People

Contributors

bendingbender avatar ranyitz avatar renovate[bot] avatar richienb avatar samverschueren avatar semantic-release-bot avatar sheerlox avatar sindresorhus avatar step-security-bot avatar

Stargazers

 avatar  avatar

Watchers

 avatar

import-from-esm's Issues

Error on npm install

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/

test: split fuzz testing from main test workflow

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.

node_modules/import-from-esm/index"' has no default export

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?

Goals & purpose of this library

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,
  • file extensions must be specified for relative path,
  • "dependencies (without an explicit path) for a given module are searched for relative to the module loading them" (source).

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.

Resources

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Unable to read vulnerability information

Pending Status Checks

These updates await pending status checks. To force their creation now, click the checkbox below.

  • chore(deps): update dependency @fast-check/ava to v1.2.1
  • chore(deps): update dependency knip to v3.8.2
  • chore(deps): update dependency tsd to v0.30.0

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.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
npm
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

  • Check this box to trigger a request for Renovate to run again on this repository

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.