Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Jul 23, 2020. It is now read-only.

Brunch plugin for 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 AMD, CommonJS, and globals styles.

License

NotificationsYou must be signed in to change notification settings

gcollazo/es6-module-transpiler-brunch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Adds ES6 module syntax toBrunch based on Square'ses6-module-transpiler.

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 AMD or CommonJS modules.

Usage

Install the plugin via npm withnpm install --save es6-module-transpiler-brunch.

Or, do manual install:

  • Add"es6-module-transpiler-brunch": "x.y.z" topackage.json of your brunch app.
  • If you want to use git version of plugin, add"es6-module-transpiler-brunch": "git+ssh://git@github.com:gcollazo/es6-module-transpiler-brunch.git".

Supported ES6 Module Syntax

Again, this syntax is in flux and is closely tracking the module work beingdone by TC39.

Named Exports

There are two types of exports.Named exports like the following:

// foobar.jsvarfoo="foo",bar="bar";export{foo,bar};

This module has two named exports,foo andbar.

You can also write this form as:

// foobar.jsexportvarfoo="foo";exportvarbar="bar";

Either way, another module can then import your exports like so:"

import{foo,bar}from"foobar";console.log(foo);// "foo"

Default Exports

You can also export adefault export. For example, an ES6ified jQuery mightlook like this:

// jquery.jsvarjQuery=function(){};jQuery.prototype={// ...};exportdefault=jQuery;

Then, an app that uses jQuery could import it with:

import$from"jquery";

The default export of the "jquery" module is now aliased to$.

A default export makes the most sense as a module's "main" export, like thejQuery object in jQuery. You can use default and named exports in parallel.

Other Syntax

module

Whereas theimport keyword imports specific identifiers from a module,themodule keyword creates an object that contains all of a module'sexports:

modulefoobarfrom"foobar";console.log(foobar.foo);// "foo"

In ES6, this created object isread-only, so don't treat it like a mutablenamespace!

import "foo";

A "bare import" that doesn't import any identifiers is useful for executingside effects in a module. For example:

// alerter.jsalert("alert! alert!");// alertee.jsimport"alerter";// will pop up alert box

How the plugin works

The plugin will take all files ending in*.js under theapp directory and pass them through thees6-module-transpiler and compiled as CommonJS modules.

Plugin Config

The plugin has two configuration options you can add to your project'sconfig.coffee:match which is a regex used to decide what files to compile anddebug which willconsole.log debugging info when the plugin runs.

exports.config=es6ModuleTranspiler:match:/^app/debug:yes

About

Brunch plugin for 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 AMD, CommonJS, and globals styles.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp