Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-module-resolver-standalone

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-module-resolver-standalone

Module resolver plugin for Babel usable in both Node.js the web browser environments

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

babel-plugin-module-resolver-standalone

NPM version devDependency Status

A Babel plugin to add a new resolver for your modules when compiling your code using Babel. This plugin allows you to transform the path of each source module using a custom JavaScript function.

This plugin can be used instead of babel-plugin-module-resolver, if the target environment is a web browser using @babel/standalone, with which the original plugin does not work. This plugin supports only the method resolvePath for the time being.

Table of Contents

Installation

This module can be installed in your project using NPM or Yarn. Make sure, that you use Node.js version 6 or newer.

npm i -D babel-plugin-module-resolver-standalone
yarn add babel-plugin-module-resolver-standalone

Babel Configuration Examples

Prepend path to utility modules to be able to import them from utils/... without always providing the actual full path:

{
  plugins: [
    [
      'module-resolver',
      {
        resolvePath: function (sourcePath, currentFile, opts) {
          if (sourcePath.startsWith('utils/')) {
            return '../../'+ sourcePath
          }
        }
      }
    ]
  ]
}

Ensure, that all JavaScript module paths are prefixed by es6!, so that requirejs-babel will be applied by RequireJS to nested modules too:

{
  plugins: [
    'transform-modules-amd',
    [
      'module-resolver',
      {
        resolvePath: function (sourcePath, currentFile, opts) {
          // Avoid prefixing modules handled by other plugins.
          if (sourcePath.indexOf('!') < 0) {
            return 'es6!' + sourcePath;
          }
        }
      }
    ]
  ]
}

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.

License

Copyright (c) 2019 Ferdinand Prantl

Licensed under the MIT license.

Keywords

FAQs

Package last updated on 27 Oct 2019

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc