Skip to content

Commit

Permalink
Merge pull request #7 from synacor/rollup-babel
Browse files Browse the repository at this point in the history
Rollup babel
  • Loading branch information
billneff79 authored Aug 4, 2017
2 parents a744255 + 64c65a0 commit 0e48b68
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 39 deletions.
7 changes: 7 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"presets": ["es2015"],
"plugins": [
"transform-object-assign",
["transform-react-jsx", { "pragma": "h", "useBuiltIns": true }]
]
}
8 changes: 1 addition & 7 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ module.exports = function(config) {
rules: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
presets: ['es2015', 'stage-0'],
plugins: [
['transform-react-jsx', { pragma: 'h' }]
]
}
loader: 'babel-loader'
}]
},
devtool: 'inline-source-map'
Expand Down
18 changes: 8 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@
"babel-core": "^6.25.0",
"babel-eslint": "^7.2.3",
"babel-loader": "^7.0.0",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-plugin-transform-react-jsx": "^6.8.0",
"babel-polyfill": "^6.9.1",
"babel-preset-es2015": "^6.9.0",
"babel-preset-es2015-minimal-rollup": "^2.0.0",
"babel-preset-stage-0": "^6.5.0",
"chai": "^4.0.2",
"chai-as-promised": "^6.0.0",
"chai-subset": "^1.2.2",
"diff": "^3.2.0",
"babelrc-rollup": "^3.0.0",
"chai": "^4.1.0",
"chai-as-promised": "^7.1.1",
"documentation": "^4.0.0-rc.1",
"documentation-theme-default": "^3.0.0-beta1",
"eslint": "^3.19.0",
Expand All @@ -77,16 +77,14 @@
"mkdirp": "^0.5.1",
"mocha": "^3.4.2",
"npm-run-all": "^4.0.2",
"phantomjs-prebuilt": "^2.1.7",
"preact": "^7.2.1",
"preact-jsx-chai": "^2.2.1",
"rimraf": "^2.5.4",
"rollup": "^0.42.0",
"rollup-plugin-babel": "^2.4.0",
"rollup-plugin-buble": "^0.15.0",
"rollup": "^0.45.2",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-memory": "^2.0.0",
"sinon": "^2.3.2",
"sinon-chai": "^2.8.0",
"sinon": "^2.4.1",
"sinon-chai": "^2.12.0",
"strip-json-comments-cli": "^1.0.1",
"uglify-js": "^2.8.28",
"webpack": "^2.6.1"
Expand Down
8 changes: 3 additions & 5 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import buble from 'rollup-plugin-buble';
import babel from 'rollup-plugin-babel';
import memory from 'rollup-plugin-memory';
import babelrc from 'babelrc-rollup'

export default {
useStrict: false,
Expand All @@ -17,9 +18,6 @@ export default {
path: 'src/entry.js',
contents: "export { default } from './index';"
}),
buble({
jsx: 'h',
objectAssign: 'assign'
})
babel(babelrc())
]
};
4 changes: 2 additions & 2 deletions src/components/intl-provider.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { h, Component } from 'preact';
import { assign, deepAssign } from '../lib/util';
import { deepAssign } from '../lib/util';


const URL_FLAG = /[?&#]intl=show/;
Expand Down Expand Up @@ -35,7 +35,7 @@ const URL_FLAG = /[?&#]intl=show/;
export class IntlProvider extends Component {
getChildContext() {
let { scope, definition, mark } = this.props,
intl = assign({}, this.context.intl || {});
intl = Object.assign({}, this.context.intl || {});

// set active scope for the tree if given
if (scope) intl.scope = scope;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/translate-mapping.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assign, select } from './util';
import { select } from './util';
import translate from './translate';
import { Text } from '../components/text';

Expand Down Expand Up @@ -27,7 +27,7 @@ export default function translateMapping(props, intl, onlyTextNodes) {
}
else if (def.nodeName===Text) {
// it's a <Text />, just grab its props:
def = assign({
def = Object.assign({
fallback: def.children && def.children[0]
}, def.attributes);
out[name] = translate(def.id, intl.scope, intl.dictionary, def.fields, def.plural, def.fallback);
Expand Down
14 changes: 1 addition & 13 deletions src/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function defined(obj) {
* @private
*/
export function deepAssign(target, source) {
let out = assign({}, target);
let out = Object.assign({}, target);
for (let i in source) {
if (source.hasOwnProperty(i)) {
if (target[i] && source[i] && typeof target[i]==='object' && typeof source[i]==='object') {
Expand All @@ -24,18 +24,6 @@ export function deepAssign(target, source) {
return out;
}


/** Object.assign() ponyfill
* @private
*/
export function assign(obj, props) {
for (let i in props) if (props.hasOwnProperty(i)) {
obj[i] = props[i];
}
return obj;
}


/** select('foo,bar') creates a mapping: `{ foo, bar }`
* @private
*/
Expand Down

0 comments on commit 0e48b68

Please sign in to comment.