![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
babel-plugin-transform-modules-iife
Advanced tools
This plugin transforms ES2015 modules to an IIFE format; reading and writing from global namespaces.
It can be used if you are only targeting browser globals, and you don't want to deal with the complexity and overhead introduced by the @babel/plugin-tansform-modules-umd plugin. The additional CommonJS and AMD logic in the UMD format can cause problems on occasion.
While the inspiration for this plugin was taken from the UMD transform plugin, the output more closely resembles that of the iife
format from rollup.
Using npm:
npm install --save-dev babel-plugin-transform-modules-iife
or using yarn:
yarn add babel-plugin-transform-modules-iife --dev
import { foo } from './foo.js';
export const bar = foo;
this.Dog = this.Dog || {};
this.Dog.Cat = this.Dog.Cat || {};
(function (_exports, _foo) {
"use strict";
const bar = _foo.foo;
_exports.bar = bar;
})(this.Dog.Cat, this.Foo.Bar.dummyRootFoo);
The plugin can be used in a normal Babel workflow like:
import babel from '@babel/core';
babel.transformFile('input.mjs', {
plugins: [['babel-plugin-transform-modules-iife', pluginOptions]]
});
...where pluginOptions
is an object with the following properties:
importNamespace
A dot-separated string that specifies the global object path containing the definitions of the objects that are imported.
exportNamespace
A dot-separated string that specifies the global object path that will be assigned the exports from the module.
importRelativePath
A path string that will be applied to the module specifier paths so the generated import variable names can be controlled to some degree.
This does not need to be an actual path on disk. It is simply used to help normalize the global variable names for the imported modules.
For example, with the following options:
{
importNameSpace: 'Dog.Cat',
importRelativePath: '/dummy/root'
}
, a statement like import { foo } from '../bar/baz.js';
would result in the import definition to be found in the global variable Dog.Cat.dummyBarBaz
.
This follows the algorithm:
importRelativePath
parameter using path.resolve(specifier, relativePath)
.importNamespace
parameter.FAQs
Transform ES2015 modules to an IIFE format
The npm package babel-plugin-transform-modules-iife receives a total of 180 weekly downloads. As such, babel-plugin-transform-modules-iife popularity was classified as not popular.
We found that babel-plugin-transform-modules-iife demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.