Socket
Book a DemoInstallSign in
Socket

babel-plugin-try-import

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-try-import

try import module

0.0.3
latest
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-try-import

try import module in webpack

what does this plugin do

convert

let react = tryImport('react');

into

let react = function () {
  let temp;

  try {
    temp = require('react').default;
  } catch (error) {}

  return temp;
}()

so that webpack won't throw error while react is not exist

convert

let hasReact = hasModule('react');

into

let hasReact = function () {
  let temp = false;

  try {
    require.resolveWeak('react');

    temp = true;
  } catch (error) {}

  return temp;
}()

so that you can check if a module exists

Keywords

babel

FAQs

Package last updated on 14 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.