4.0.0 • Published 4 years ago

import-from v4.0.0

Weekly downloads
9,895,778
License
MIT
Repository
github
Last release
4 years ago

import-from

Import a module like with require() but from a given path

Install

$ npm install import-from

Usage

const importFrom = require('import-from');

// There is a file at `./foo/bar.js`

importFrom('foo', './bar');

API

importFrom(fromDirectory, moduleId)

Like require(), throws when the module can't be found.

importFrom.silent(fromDirectory, moduleId)

Returns undefined instead of throwing when the module can't be found.

fromDirectory

Type: string

Directory to import from.

moduleId

Type: string

What you would use in require().

Tip

Create a partial using a bound function if you want to import from the same fromDir multiple times:

const importFromFoo = importFrom.bind(null, 'foo');

importFromFoo('./bar');
importFromFoo('./baz');

Related

  • import-cwd - Import a module from the current working directory
  • resolve-from - Resolve the path of a module from a given path
  • resolve-cwd - Resolve the path of a module from the current working directory
  • resolve-pkg - Resolve the path of a package regardless of it having an entry point
  • import-lazy - Import modules lazily
  • import-global - Import a globally installed module
import-cwd@graphql-codegen/plugin-helpersarchetype-libraryvuedragdropuploadimagesreact-native-bluetooth2killi8n-react-native-fast-imagea-xyj-test@penumbra/clicloud-archive-s3airscanairscan-examplebb-chatreact-native-esc-pos-sahaab@borisovart/atol-kkt-moduledeneme323112@fundefund/funde_ck@ntt_app/react-native-custom-notificationreact-native-covid-sdk@olivervorasai/sliderreact-native-printer-brotherscogoportutils@mink-opn/build-tokens@infinitebrahmanuniverse/nolb-imp@prodam/prodam-types@saaspe/componentsexpand-react-bridge@everything-registry/sub-chunk-1908p149-tabletest-popupsmedusa_valktailwindcss-types-clitailwind-templatewikicvue-button-test1webpack-reportstories-react-bdspiresvavatarvue-compmentvision-camera-plugin-scan-facesvs-tree-plus@dimcheify/dimui@coat/cli@cristianps1988/ds-template@cromwell/utils@credix/release-notes-generator-filtered@ct-note/table@ct-note/image@ct-note/list@ct-note/checklist@ct-note/embed@commitlint/config-lerna-scopes@condenast/commit-analyzer@corelmax/react-native-my2c2p-sdk@dinert/componentjest-allure2-reporterirontailjest-environment-hopsjesusdemojest-preset-hopsjest-preset-nsjnf-accesscontrol-rnttlinst-clikap-plugin-test@esciara-semantic-release/manual-bumpspigot-ui-inventorystock-ticker-react-widgettype-libarytwo-from-nowtingzi-vuepressu-librarytiztldrawlignintwine-libtwine-library@apardellass/react-native-audio-stream@aristidenf/streak-counter@asiz33/smartblok-vendure-plugin@auto-canary/core@arkasuryawan/m2-interface@auto-it/core@alicd/cone-cli@aws-amplify/amplify-category-api@blazinaj/app-kit@binance-chain/commitlint-config@binancechain/commitlint-config@carhoo/widget-dealers@cfware/fastify-test-helper-cli@clearcover/commit-analyzer@charcoal-ui/tailwind-diff@decisiv/semantic-release-plugin-decorators@devorso/dcountdown@contagt/metismenu@daotl/ts-lib-starterzoro-cli-utilzqyan-clivue-v3-yandex-metrikavue3-google-login-with-statewebql-codegen-plugin-helperswebpack-cyo-dashboard
4.0.0

4 years ago

3.0.0

6 years ago

2.1.0

8 years ago