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

broccoli-es6modules

Package Overview
Dependencies
Maintainers
3
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broccoli-es6modules - npm Package Compare versions

Comparing version 0.5.1 to 0.6.0

test/expected/amd/custom-ext.es3

26

index.js

@@ -104,3 +104,3 @@ var CachingWriter = require('broccoli-caching-writer');

* For per-file transpilations if the format is 'namedAmd', the 'amdName' option passed to the transpiler
for each file will be the files relative file path, with '.js' stripped from it.
for each file will be the file's relative file path, with '.js' stripped from it.
* For per-file transpilations if `sourceMap` option is provided, the `sourceMapSource` option is passed

@@ -155,2 +155,3 @@ to the transpiler for each file as the relative file path, with '.js' stripped from it.

var transpilerName = formatToFunctionName[this.format];
var targetExtension = this.targetExtension;

@@ -162,3 +163,3 @@ return esperanto.bundle({

var compiledModule = bundle[transpilerName](opts);
var fullOutputPath = path.join(outDir, name + ".js");
var fullOutputPath = path.join(outDir, name + '.' + targetExtension);

@@ -187,3 +188,3 @@ return writeFile(fullOutputPath, compiledModule.code);

.forEach(function(relativePath) {
if (relativePath.slice(-1) !== '/') {
if (this._shouldProcessFile(relativePath)) {
this._handleFile(inDir, outDir, relativePath, _newTranspilerCache);

@@ -202,5 +203,6 @@ }

_handleFile: function(inDir, outDir, relativePath, newCache) {
var moduleName = relativePath.replace(/\.js$/, '');
var ext = this._matchingFileExtension(relativePath);
var moduleName = relativePath.slice(0, relativePath.length - (ext.length + 1));
var fullInputPath = path.join(inDir, relativePath);
var fullOutputPath = path.join(outDir, relativePath);
var fullOutputPath = path.join(outDir, moduleName + '.' + this.targetExtension);

@@ -268,3 +270,17 @@ var entry = this._transpileThroughCache(

return options;
},
extensions: ['js'],
targetExtension: 'js',
_matchingFileExtension: function(relativePath) {
for (var i = 0; i < this.extensions.length; i++) {
var ext = this.extensions[i];
if (relativePath.slice(-ext.length - 1) === '.' + ext) {
return ext;
}
}
return null;
},
_shouldProcessFile: function(relativePath) {
return !!this._matchingFileExtension(relativePath);
}
});

2

package.json
{
"name": "broccoli-es6modules",
"version": "0.5.1",
"version": "0.6.0",
"description": "An es6 module transpiler & concatenator for broccoli.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -211,4 +211,68 @@ /* global describe, afterEach, it, expect */

it('compiles with custom source extensions', function(){
var tree = new ES6(fixtures, {
format: 'amd',
extensions: ['es6'],
esperantoOptions: {
strict: true
}
});
builder = new broccoli.Builder(tree);
return builder.build().then(function(result) {
expectFile('custom-ext.js', 'amd').in(result);
});
});
it('compiles with more than one source extension', function(){
var tree = new ES6(fixtures, {
format: 'amd',
extensions: ['es6', 'js'],
esperantoOptions: {
strict: true
}
});
builder = new broccoli.Builder(tree);
return builder.build().then(function(result) {
expectFile('custom-ext.js', 'amd').in(result);
expectFile('reexport.js', 'amd').in(result);
expectFile('outer.js', 'amd').in(result);
});
});
it('compiles using custom target extensions', function(){
var tree = new ES6(fixtures, {
format: 'amd',
targetExtension: 'es3',
esperantoOptions: {
strict: true
}
});
builder = new broccoli.Builder(tree);
return builder.build().then(function(result) {
expectFile('reexport.es3', 'amd').in(result);
expectFile('outer.es3', 'amd').in(result);
});
});
it('compiles using custom target extensions and source extensions', function(){
var tree = new ES6(fixtures, {
format: 'amd',
extensions: ['es6', 'js'],
targetExtension: 'es3',
esperantoOptions: {
strict: true
}
});
builder = new broccoli.Builder(tree);
return builder.build().then(function(result) {
expectFile('custom-ext.es3', 'amd').in(result);
expectFile('reexport.es3', 'amd').in(result);
expectFile('outer.es3', 'amd').in(result);
});
});
afterEach(function() {

@@ -250,3 +314,3 @@ if (builder) {

} catch (err) {
console.warn("Missing expcted file: " + path.join(__dirname, 'expected', format, filename));
console.warn("Missing expected file: " + path.join(__dirname, 'expected', format, filename));
}

@@ -253,0 +317,0 @@

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