summaryrefslogtreecommitdiffstats
path: root/node_modules/babel-plugin-transform-es2015-modules-umd
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/babel-plugin-transform-es2015-modules-umd')
-rw-r--r--node_modules/babel-plugin-transform-es2015-modules-umd/.npmignore3
-rw-r--r--node_modules/babel-plugin-transform-es2015-modules-umd/README.md214
-rw-r--r--node_modules/babel-plugin-transform-es2015-modules-umd/lib/index.js127
-rw-r--r--node_modules/babel-plugin-transform-es2015-modules-umd/package.json47
4 files changed, 0 insertions, 391 deletions
diff --git a/node_modules/babel-plugin-transform-es2015-modules-umd/.npmignore b/node_modules/babel-plugin-transform-es2015-modules-umd/.npmignore
deleted file mode 100644
index 47cdd2c..0000000
--- a/node_modules/babel-plugin-transform-es2015-modules-umd/.npmignore
+++ /dev/null
@@ -1,3 +0,0 @@
-src
-test
-node_modules
diff --git a/node_modules/babel-plugin-transform-es2015-modules-umd/README.md b/node_modules/babel-plugin-transform-es2015-modules-umd/README.md
deleted file mode 100644
index fe32773..0000000
--- a/node_modules/babel-plugin-transform-es2015-modules-umd/README.md
+++ /dev/null
@@ -1,214 +0,0 @@
-# babel-plugin-transform-es2015-modules-umd
-
-> This plugin transforms ES2015 modules to [Universal Module Definition (UMD)](https://github.com/umdjs/umd).
-
-## Example
-
-**In**
-
-```javascript
-export default 42;
-```
-
-**Out**
-
-```javascript
-(function (global, factory) {
- if (typeof define === "function" && define.amd) {
- define(["exports"], factory);
- } else if (typeof exports !== "undefined") {
- factory(exports);
- } else {
- var mod = {
- exports: {}
- };
- factory(mod.exports);
- global.actual = mod.exports;
- }
-})(this, function (exports) {
- "use strict";
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
-
- exports.default = 42;
-});
-```
-
-## Installation
-
-```sh
-npm install --save-dev babel-plugin-transform-es2015-modules-umd
-```
-
-## Usage
-
-### Via `.babelrc` (Recommended)
-
-**.babelrc**
-
-```json
-{
- "plugins": ["transform-es2015-modules-umd"]
-}
-```
-
-You can also override the names of particular libraries when this module is
-running in the browser. For example the `es6-promise` library exposes itself
-as `global.Promise` rather than `global.es6Promise`. This can be accommodated by:
-
-```json
-{
- "plugins": [
- ["transform-es2015-modules-umd", {
- "globals": {
- "es6-promise": "Promise"
- }
- }]
- ]
-}
-```
-
-#### Default semantics
-
-There are a few things to note about the default semantics.
-
-_First_, this transform uses the
-[basename](https://en.wikipedia.org/wiki/Basename) of each import to generate
-the global names in the UMD output. This means that if you're importing
-multiple modules with the same basename, like:
-
-```js
-import fooBar1 from "foo-bar";
-import fooBar2 from "./mylib/foo-bar";
-```
-
-it will transpile into two references to the same browser global:
-
-```js
-factory(global.fooBar, global.fooBar);
-```
-
-If you set the plugin options to:
-
-```json
-{
- "globals": {
- "foo-bar": "fooBAR",
- "./mylib/foo-bar": "mylib.fooBar"
- }
-}
-```
-
-it will still transpile both to one browser global:
-
-```js
-factory(global.fooBAR, global.fooBAR);
-```
-
-because again the transform is only using the basename of the import.
-
-_Second_, the specified override will still be passed to the `toIdentifier`
-function in [babel-types/src/converters](https://github.com/babel/babel/blob/master/packages/babel-types/src/converters.js).
-This means that if you specify an override as a member expression like:
-
-```json
-{
- "globals": {
- "fizzbuzz": "fizz.buzz"
- }
-}
-```
-
-this will _not_ transpile to `factory(global.fizz.buzz)`. Instead, it will
-transpile to `factory(global.fizzBuzz)` based on the logic in `toIdentifier`.
-
-_Third_, you cannot override the exported global name.
-
-#### More flexible semantics with `exactGlobals: true`
-
-All of these behaviors can limit the flexibility of the `globals` map. To
-remove these limitations, you can set the `exactGlobals` option to `true`.
-Doing this instructs the plugin to:
-
-1. always use the full import string instead of the basename when generating
-the global names
-2. skip passing `globals` overrides to the `toIdentifier` function. Instead,
-they are used exactly as written, so you will get errors if you do not use
-valid identifiers or valid uncomputed (dot) member expressions.
-3. allow the exported global name to be overridden via the `globals` map. Any
-override must again be a valid identifier or valid member expression.
-
-Thus, if you set `exactGlobals` to `true` and do not pass any overrides, the
-first example of:
-
-```js
-import fooBar1 from "foo-bar";
-import fooBar2 from "./mylib/foo-bar";
-```
-
-will transpile to:
-
-```js
-factory(global.fooBar, global.mylibFooBar);
-```
-
-And if you set the plugin options to:
-
-```json
-{
- "globals": {
- "foo-bar": "fooBAR",
- "./mylib/foo-bar": "mylib.fooBar"
- },
- "exactGlobals": true
-}
-```
-
-then it'll transpile to:
-
-```js
-factory(global.fooBAR, global.mylib.fooBar)
-```
-
-Finally, with the plugin options set to:
-
-```json
-{
- "plugins": [
- "external-helpers",
- ["transform-es2015-modules-umd", {
- "globals": {
- "my/custom/module/name": "My.Custom.Module.Name"
- },
- "exactGlobals": true
- }]
- ],
- "moduleId": "my/custom/module/name"
-}
-```
-
-it will transpile to:
-
-```js
-factory(mod.exports);
-global.My = global.My || {};
-global.My.Custom = global.My.Custom || {};
-global.My.Custom.Module = global.My.Custom.Module || {};
-global.My.Custom.Module.Name = mod.exports;
-```
-
-### Via CLI
-
-```sh
-babel --plugins transform-es2015-modules-umd script.js
-```
-
-### Via Node API
-
-```javascript
-require("babel-core").transform("code", {
- plugins: ["transform-es2015-modules-umd"]
-});
-```
diff --git a/node_modules/babel-plugin-transform-es2015-modules-umd/lib/index.js b/node_modules/babel-plugin-transform-es2015-modules-umd/lib/index.js
deleted file mode 100644
index d537971..0000000
--- a/node_modules/babel-plugin-transform-es2015-modules-umd/lib/index.js
+++ /dev/null
@@ -1,127 +0,0 @@
-"use strict";
-
-exports.__esModule = true;
-
-exports.default = function (_ref) {
- var t = _ref.types;
-
- function isValidDefine(path) {
- if (!path.isExpressionStatement()) return;
-
- var expr = path.get("expression");
- if (!expr.isCallExpression()) return false;
- if (!expr.get("callee").isIdentifier({ name: "define" })) return false;
-
- var args = expr.get("arguments");
- if (args.length === 3 && !args.shift().isStringLiteral()) return false;
- if (args.length !== 2) return false;
- if (!args.shift().isArrayExpression()) return false;
- if (!args.shift().isFunctionExpression()) return false;
-
- return true;
- }
-
- return {
- inherits: require("babel-plugin-transform-es2015-modules-amd"),
-
- visitor: {
- Program: {
- exit: function exit(path, state) {
- var last = path.get("body").pop();
- if (!isValidDefine(last)) return;
-
- var call = last.node.expression;
- var args = call.arguments;
-
- var moduleName = args.length === 3 ? args.shift() : null;
- var amdArgs = call.arguments[0];
- var func = call.arguments[1];
- var browserGlobals = state.opts.globals || {};
-
- var commonArgs = amdArgs.elements.map(function (arg) {
- if (arg.value === "module" || arg.value === "exports") {
- return t.identifier(arg.value);
- } else {
- return t.callExpression(t.identifier("require"), [arg]);
- }
- });
-
- var browserArgs = amdArgs.elements.map(function (arg) {
- if (arg.value === "module") {
- return t.identifier("mod");
- } else if (arg.value === "exports") {
- return t.memberExpression(t.identifier("mod"), t.identifier("exports"));
- } else {
- var memberExpression = void 0;
-
- if (state.opts.exactGlobals) {
- var globalRef = browserGlobals[arg.value];
- if (globalRef) {
- memberExpression = globalRef.split(".").reduce(function (accum, curr) {
- return t.memberExpression(accum, t.identifier(curr));
- }, t.identifier("global"));
- } else {
- memberExpression = t.memberExpression(t.identifier("global"), t.identifier(t.toIdentifier(arg.value)));
- }
- } else {
- var requireName = (0, _path.basename)(arg.value, (0, _path.extname)(arg.value));
- var globalName = browserGlobals[requireName] || requireName;
- memberExpression = t.memberExpression(t.identifier("global"), t.identifier(t.toIdentifier(globalName)));
- }
-
- return memberExpression;
- }
- });
-
- var moduleNameOrBasename = moduleName ? moduleName.value : this.file.opts.basename;
- var globalToAssign = t.memberExpression(t.identifier("global"), t.identifier(t.toIdentifier(moduleNameOrBasename)));
- var prerequisiteAssignments = null;
-
- if (state.opts.exactGlobals) {
- var globalName = browserGlobals[moduleNameOrBasename];
-
- if (globalName) {
- prerequisiteAssignments = [];
-
- var members = globalName.split(".");
- globalToAssign = members.slice(1).reduce(function (accum, curr) {
- prerequisiteAssignments.push(buildPrerequisiteAssignment({ GLOBAL_REFERENCE: accum }));
- return t.memberExpression(accum, t.identifier(curr));
- }, t.memberExpression(t.identifier("global"), t.identifier(members[0])));
- }
- }
-
- var globalExport = buildGlobalExport({
- BROWSER_ARGUMENTS: browserArgs,
- PREREQUISITE_ASSIGNMENTS: prerequisiteAssignments,
- GLOBAL_TO_ASSIGN: globalToAssign
- });
-
- last.replaceWith(buildWrapper({
- MODULE_NAME: moduleName,
- AMD_ARGUMENTS: amdArgs,
- COMMON_ARGUMENTS: commonArgs,
- GLOBAL_EXPORT: globalExport,
- FUNC: func
- }));
- }
- }
- }
- };
-};
-
-var _path = require("path");
-
-var _babelTemplate = require("babel-template");
-
-var _babelTemplate2 = _interopRequireDefault(_babelTemplate);
-
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
-var buildPrerequisiteAssignment = (0, _babelTemplate2.default)("\n GLOBAL_REFERENCE = GLOBAL_REFERENCE || {}\n");
-
-var buildGlobalExport = (0, _babelTemplate2.default)("\n var mod = { exports: {} };\n factory(BROWSER_ARGUMENTS);\n PREREQUISITE_ASSIGNMENTS\n GLOBAL_TO_ASSIGN = mod.exports;\n");
-
-var buildWrapper = (0, _babelTemplate2.default)("\n (function (global, factory) {\n if (typeof define === \"function\" && define.amd) {\n define(MODULE_NAME, AMD_ARGUMENTS, factory);\n } else if (typeof exports !== \"undefined\") {\n factory(COMMON_ARGUMENTS);\n } else {\n GLOBAL_EXPORT\n }\n })(this, FUNC);\n");
-
-module.exports = exports["default"]; \ No newline at end of file
diff --git a/node_modules/babel-plugin-transform-es2015-modules-umd/package.json b/node_modules/babel-plugin-transform-es2015-modules-umd/package.json
deleted file mode 100644
index 33748fd..0000000
--- a/node_modules/babel-plugin-transform-es2015-modules-umd/package.json
+++ /dev/null
@@ -1,47 +0,0 @@
-{
- "_from": "babel-plugin-transform-es2015-modules-umd@^6.24.1",
- "_id": "babel-plugin-transform-es2015-modules-umd@6.24.1",
- "_inBundle": false,
- "_integrity": "sha1-rJl+YoXNGO1hdq22B9YCNErThGg=",
- "_location": "/babel-plugin-transform-es2015-modules-umd",
- "_phantomChildren": {},
- "_requested": {
- "type": "range",
- "registry": true,
- "raw": "babel-plugin-transform-es2015-modules-umd@^6.24.1",
- "name": "babel-plugin-transform-es2015-modules-umd",
- "escapedName": "babel-plugin-transform-es2015-modules-umd",
- "rawSpec": "^6.24.1",
- "saveSpec": null,
- "fetchSpec": "^6.24.1"
- },
- "_requiredBy": [
- "/babel-preset-es2015"
- ],
- "_resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz",
- "_shasum": "ac997e6285cd18ed6176adb607d602344ad38468",
- "_spec": "babel-plugin-transform-es2015-modules-umd@^6.24.1",
- "_where": "/home/pruss/Dev/3-minute-website/node_modules/babel-preset-es2015",
- "bundleDependencies": false,
- "dependencies": {
- "babel-plugin-transform-es2015-modules-amd": "^6.24.1",
- "babel-runtime": "^6.22.0",
- "babel-template": "^6.24.1"
- },
- "deprecated": false,
- "description": "This plugin transforms ES2015 modules to UMD",
- "devDependencies": {
- "babel-helper-plugin-test-runner": "^6.24.1"
- },
- "keywords": [
- "babel-plugin"
- ],
- "license": "MIT",
- "main": "lib/index.js",
- "name": "babel-plugin-transform-es2015-modules-umd",
- "repository": {
- "type": "git",
- "url": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-modules-umd"
- },
- "version": "6.24.1"
-}