Build as ES module as well as CommonJS

nolan/hinaloe-test
Nolan Lawson 2017-09-23 17:06:29 -07:00
parent bbd4fbe764
commit fdc91d0733
11 changed files with 26 additions and 13 deletions

View File

@ -12,7 +12,6 @@
"transform-es2015-for-of",
"transform-es2015-function-name",
"transform-es2015-literals",
"transform-es2015-modules-commonjs",
"transform-es2015-object-super",
"transform-es2015-parameters",
"transform-es2015-shorthand-properties",
@ -40,5 +39,12 @@
}
}
]
]
],
"env": {
"cjs": {
"plugins": [
"transform-es2015-modules-commonjs"
]
}
}
}

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
node_modules/
dist/
dist-es/
bundle.js

View File

@ -3,6 +3,7 @@
"version": "2.0.1",
"description": "Customizable Slack-like emoji picker for React",
"main": "dist/index.js",
"module": "dist-es/index.js",
"repository": {
"type": "git",
"url": "git@github.com:missive/emoji-mart.git"
@ -61,11 +62,13 @@
"webpack": "^3.6.0"
},
"scripts": {
"clean": "rm -rf dist/",
"clean": "rm -rf dist/ dist-es/",
"build:data": "node scripts/build-data",
"build:dist": "npm run clean && babel src --out-dir dist --copy-files --ignore webpack.config.js",
"build:dist": "npm run clean && npm run build:cjs && npm run build:es",
"build:cjs": "BABEL_ENV=cjs babel src --out-dir dist --copy-files --ignore webpack.config.js",
"build:es": "babel src --out-dir dist-es --copy-files --ignore webpack.config.js",
"build": "npm run build:dist && npm run build:data",
"watch": "babel src --watch --out-dir dist --copy-files --ignore webpack.config.js",
"watch": "BABEL_ENV=cjs babel src --watch --out-dir dist --copy-files --ignore webpack.config.js",
"start": "npm run watch",
"stats": "webpack --config ./src/webpack.config.js --json > stats.json",
"react:clean": "rimraf node_modules/{react,react-dom,react-addons-test-utils}",

View File

@ -143,4 +143,7 @@ flags.emojis = flags.emojis.filter((flag) => {
const stringified = JSON.stringify(data).replace(/\"([A-Za-z_]+)\":/g, '$1:')
fs.writeFile('dist/data/data.js', `module.exports = ${stringified}`, (err) => {
if (err) throw err
fs.writeFile('dist-es/data/data.js', `export default ${stringified}`, (err) => {
if (err) throw err
})
})

View File

@ -1,6 +1,6 @@
const _Object = Object
module.exports = function createClass() {
export default (function createClass() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
@ -16,4 +16,4 @@ module.exports = function createClass() {
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
}());

View File

@ -1,6 +1,6 @@
const _Object = Object
module.exports = _Object.assign || function (target) {
export default _Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];

View File

@ -1,6 +1,6 @@
const _Object = Object
module.exports = function inherits(subClass, superClass) {
export default function inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}

View File

@ -1,6 +1,6 @@
const _Object = Object
module.exports = _Object.getPrototypeOf || function (O) {
export default _Object.getPrototypeOf || function (O) {
O = Object(O)
if (typeof O.constructor === 'function' && O instanceof O.constructor) {

View File

@ -1,4 +1,4 @@
module.exports = function possibleConstructorReturn(self, call) {
export default function possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}

View File

@ -1,6 +1,6 @@
const _String = String
module.exports = _String.fromCodePoint || function stringFromCodePoint() {
export default _String.fromCodePoint || function stringFromCodePoint() {
var MAX_SIZE = 0x4000;
var codeUnits = [];
var highSurrogate;

View File

@ -1,4 +1,4 @@
module.exports = data => {
export default data => {
const search = []
var addToSearch = (strings, split) => {