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-plusjest-allure2-reporterirontailjest-environment-hopsjesusdemojest-preset-hopsjest-preset-nsjnf-accesscontrol-rnttlinst-clikap-plugin-testimport-from-fallbackhttehot-zone-vuehtml-external-webpack-pluginholy-medusahantil-csshaste-clihelp-widgetlitepie-datepicker-gabelucas-gqlmaodam2m-chartjs-plugin-crosshairladle-react-nativekungfu-clikrown_login_librarymavectra@wecraftapps/react-native-use-keyboard@vue-helper/vue-keep-alive@tiga-cli/tpl-core@tillschweneker/ckeditor5-build-strapi-wysiwyg-markdown@tuber/choc@ttionya/test@teka15/release-notes-generator@yplabs-ltd/react-native-detector@yak-spirit/yak-swap-ui@ykominami/xcomp@zeplin/cli@zebracompany/f_editor@zm-credit/miniapp-cli@zyyjs/cone-clibabel-plugin-markdownant-design-draggable-modal-fixap-vue-captchaappcharge-checkout@itayn-fireberry-org/itayn-test@itandu/utils@clearcover/commit-analyzer@graines-digitales/nice-handsome-button@graphql-toolkit/core@graphql-tools/core@happy-gastro/react-native-printer-module@ebay/muse-core@effective/prettier@coat/cli@contagt/metismenu@cristianps1988/ds-template@cromwell/utils@credix/release-notes-generator-filtered@condenast/commit-analyzer@alicd/cone-cli
4.0.0

4 years ago

3.0.0

6 years ago

2.1.0

8 years ago