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

es6-module-transpiler

Package Overview
Dependencies
Maintainers
3
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es6-module-transpiler - npm Package Compare versions

Comparing version 0.9.6 to 0.10.0

10

lib/file_resolver.js

@@ -70,8 +70,16 @@ /* jshint node:true, undef:true, unused:true */

var resolved = Path.resolve(includePath, importedPath);
if (resolved.slice(-3).toLowerCase() !== '.js') {
if (!~resolved.lastIndexOf('.')) {
resolved += '.js';
}
if (fs.existsSync(resolved)) {
return resolved;
}
// edge cases when a module may have dotted filename, i.e. jquery.min.js
// and the module name is passed without the extension
resolved += '.js';
if (fs.existsSync(resolved)) {
return resolved;
}
}

@@ -78,0 +86,0 @@

35

lib/formatters/commonjs_formatter.js

@@ -11,2 +11,3 @@ /* jshint node:true, undef:true, unused:true */

var extend = require('../utils').extend;
var compatMemberExpression = require('../utils').compatMemberExpression;
var Replacement = require('../replacement');

@@ -80,6 +81,5 @@ var Formatter = require('./formatter');

'=',
b.memberExpression(
compatMemberExpression(
exportObject,
b.identifier(name),
false
name
),

@@ -140,6 +140,5 @@ b.identifier(specifier.from)

'=',
b.memberExpression(
compatMemberExpression(
exportObject,
b.identifier(name),
false
name
),

@@ -250,3 +249,3 @@ from

// function foo () {}
// export.default = foo;
// export['default'] = foo;
return [

@@ -415,6 +414,5 @@ declaration,

'=',
b.memberExpression(
compatMemberExpression(
b.identifier('exports'),
b.identifier(exportName),
false
exportName
),

@@ -439,6 +437,5 @@ b.identifier(exportName)

'=',
b.memberExpression(
compatMemberExpression(
b.identifier('exports'),
b.identifier(exportName),
false
exportName
),

@@ -472,6 +469,5 @@ b.identifier(exportName)

'=',
b.memberExpression(
compatMemberExpression(
b.identifier('exports'),
b.identifier(exportName),
false
exportName
),

@@ -531,3 +527,3 @@ node

* // rsvp/defer.js, export default
* rsvp$defer$$.default
* rsvp$defer$$['default']
*

@@ -543,6 +539,5 @@ * // rsvp/utils.js, export function isFunction

CommonJSFormatter.prototype.reference = function(mod, identifier) {
return b.memberExpression(
return compatMemberExpression(
b.identifier(mod.id),
n.Identifier.check(identifier) ? identifier : b.identifier(identifier),
false
identifier
);

@@ -549,0 +544,0 @@ };

@@ -6,3 +6,3 @@ /* jshint node:true, undef:true, unused:true */

var b = recast.types.builders;
var esprima = require('esprima-fb');
var reserved = require('reserved');
var realFS = require('fs');

@@ -84,2 +84,29 @@ var Path = require('path');

/**
* Create a member express that is compatible with ES3. Which means
* reserved words will be treated as computed props. E.g.:
*
* foo["default"] // instead of `foo.default`
*
* while still supporting identifiers for non-reserved words:
*
* foo.bar // since bar is not reserved
*
* @param {Identifier} obj Identifier for the object reference
* @param {Identifier|String} prop Identifier or string name for the member property
* @return {b.memberExpression} AST for the member expression
*/
function compatMemberExpression(obj, prop) {
var isIdentifier = n.Identifier.check(prop);
var name = isIdentifier ? prop.name : prop;
var computed = reserved.indexOf(name) >= 0;
return b.memberExpression(
obj,
computed ? b.literal(name) : (isIdentifier ? prop : b.identifier(prop)),
computed
);
}
exports.compatMemberExpression = compatMemberExpression;
/**
* Create a hierarchy of directories of it does not already exist.

@@ -86,0 +113,0 @@ *

{
"name": "es6-module-transpiler",
"version": "0.9.6",
"version": "0.10.0",
"description": "es6-module-transpiler is an experimental compiler that allows you to write your JavaScript using a subset of the current ES6 module syntax, and compile it into various formats.",

@@ -40,3 +40,3 @@ "homepage": "http://esnext.github.io/es6-module-transpiler",

"author": "Square, Inc.",
"license": "Apache 2",
"license": "Apache-2.0",
"dependencies": {

@@ -46,3 +46,4 @@ "ast-util": "^0.5.1",

"posix-getopt": "^1.0.0",
"recast": "^0.9.5"
"recast": "^0.9.5",
"reserved": "^0.1.2"
},

@@ -49,0 +50,0 @@ "devDependencies": {

@@ -21,3 +21,3 @@ # ES6 Module Transpiler [![Build Status](https://travis-ci.org/esnext/es6-module-transpiler.png)](https://travis-ci.org/esnext/es6-module-transpiler)

* **Grunt:** [grunt-es6-module-transpiler](https://github.com/joefiorini/grunt-es6-module-transpiler), maintained by @joefiorini (not yet compatible with v0.5.x)
* **Gulp:** [gulp-es6-module-transpiler](https://github.com/ryanseddon/gulp-es6-module-transpiler), maintained by @ryanseddon (not yet compatible with v0.5.x)
* **Gulp:** [gulp-es6-module-transpiler](https://github.com/ryanseddon/gulp-es6-module-transpiler), maintained by @ryanseddon
* **Brunch:** [es6-module-transpiler-brunch](https://github.com/gcollazo/es6-module-transpiler-brunch), maintained by @gcollazo *(CommonJS only)* (not yet compatible with v0.5.x)

@@ -24,0 +24,0 @@ * **Broccoli:** [broccoli-es6-concatenator](https://github.com/joliss/broccoli-es6-concatenator), maintained by @joliss (not yet compatible with v0.5.x)

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