šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

babel-plugin-modules-web-compat

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-modules-web-compat

A Babel plugin that rewrites module specifiers to be web compatible.

1.1.1
latest
Source
npm
Version published
Weekly downloads
7
-22.22%
Maintainers
2
Weekly downloads
Ā 
Created
Source

babel-plugin-modules-web-compat

A Babel plugin that rewrites module specifiers to be web compatible.

For example, this code:

import { Component } from 'preact';
import * as util from './util';

Will be transformed into:

import { Component } from './node_modules/preact/dist/preact.js';
import * as util from './util/index.js';

Making it possible to load in browsers that support <script type="module">.

Install

yarn add babel-plugin-modules-web-compat --dev

Usage

In your .babelrc add:

{
  "plugins": [
    "modules-web-compat"
  ]
}

To prepare your modules for distribution to npm, it will need to resolve npm dependencies to the parent folder. Use packageResolutionStrategy to turn on this behavior:

{
  "plugins": [
    ["modules-web-compat", {
      "packageResolutionStrategy": "npm"
    }]
  ]
}

Which will add an addition ../ to your npm dependency specifiers.

License

BSD 2 Clause

FAQs

Package last updated on 17 Aug 2017

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