Permalink
Browse files

Convert CommonJS module definition to ES6 modules

As mentioned in #108 (comment)

This was done with the help of [lebab], using `lebab --replace src --transform commonjs`.

[lebab]: https://github.com/lebab/lebab

It also required an additional babel plugin to compile back to CommonJS
https://github.com/59naga/babel-plugin-add-module-exports
  • Loading branch information...
josephfrazier authored and slevithan committed Apr 30, 2017
1 parent 53060d8 commit b3133fcec31e252e4bc459ac0d896dac85bef23b
View
@@ -1,5 +1,6 @@
{
"plugins": [
"add-module-exports",
"transform-xregexp",
"array-includes"
],
View
@@ -33,6 +33,7 @@
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-array-includes": "^2.0.3",
"babel-plugin-transform-xregexp": "^0.0.4",
"babel-preset-env": "^1.4.0",
View
@@ -4,7 +4,7 @@
* Steven Levithan (c) 2012-2017 MIT License
*/
module.exports = (XRegExp) => {
export default (XRegExp) => {
const REGEX_DATA = 'xregexp';
const subParts = /(\()(?!\?)|\\([1-9]\d*)|\\[\s\S]|\[(?:[^\\\]]|\\[\s\S])*\]/g;
const parts = XRegExp.union([/\({{([\w$]+)}}\)|{{([\w$]+)}}/, subParts], 'g', {
@@ -4,7 +4,7 @@
* Steven Levithan (c) 2009-2017 MIT License
*/
module.exports = (XRegExp) => {
export default (XRegExp) => {
/**
* Returns a match detail object composed of the provided values.
@@ -4,7 +4,7 @@
* Steven Levithan (c) 2008-2017 MIT License
*/
module.exports = (XRegExp) => {
export default (XRegExp) => {
/**
* Adds base support for Unicode matching:
@@ -5,7 +5,7 @@
* Unicode data by Mathias Bynens <mathiasbynens.be>
*/
module.exports = (XRegExp) => {
export default (XRegExp) => {
/**
* Adds support for all Unicode blocks. Block names use the prefix 'In'. E.g.,

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -5,7 +5,7 @@
* Unicode data by Mathias Bynens <mathiasbynens.be>
*/
module.exports = (XRegExp) => {
export default (XRegExp) => {
/**
* Adds support for all Unicode scripts. E.g., `\p{Latin}`. Token names are case insensitive,
View
@@ -1,11 +1,19 @@
const XRegExp = require('./xregexp');
import XRegExp from './xregexp';
require('./addons/build')(XRegExp);
require('./addons/matchrecursive')(XRegExp);
require('./addons/unicode-base')(XRegExp);
require('./addons/unicode-blocks')(XRegExp);
require('./addons/unicode-categories')(XRegExp);
require('./addons/unicode-properties')(XRegExp);
require('./addons/unicode-scripts')(XRegExp);
import build from './addons/build';
import matchrecursive from './addons/matchrecursive';
import unicodeBase from './addons/unicode-base';
import unicodeBlocks from './addons/unicode-blocks';
import unicodeCategories from './addons/unicode-categories';
import unicodeProperties from './addons/unicode-properties';
import unicodeScripts from './addons/unicode-scripts';
module.exports = XRegExp;
build(XRegExp);
matchrecursive(XRegExp);
unicodeBase(XRegExp);
unicodeBlocks(XRegExp);
unicodeCategories(XRegExp);
unicodeProperties(XRegExp);
unicodeScripts(XRegExp);
export default XRegExp;
View
@@ -1890,4 +1890,4 @@ XRegExp.addToken(
}
);
module.exports = XRegExp;
export default XRegExp;

0 comments on commit b3133fc

Please sign in to comment.