Skip to content

Commit 3ba6c89

Browse files
committed
Switch build to rollup + babel 6 instead of raw babel 5.
1 parent 97b440e commit 3ba6c89

File tree

9 files changed

+118
-22
lines changed

9 files changed

+118
-22
lines changed

.babelrc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
2-
"loose": "all",
3-
"modules": "umd",
4-
"sourceMaps": true,
5-
"nonStandard": true,
6-
"compact": true,
7-
"comments": false,
8-
"jsxPragma": "h"
2+
"presets": [
3+
"es2015-minimal",
4+
"stage-0"
5+
],
6+
"plugins": [
7+
"transform-class-properties",
8+
["transform-react-jsx", {"pragma":"h"}]
9+
]
910
}

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,55 @@
11
{
22
"parser": "babel-eslint",
3-
"ignore": ["*.md"]
3+
"extends": "eslint:recommended",
4+
"env": {
5+
"browser": true,
6+
"mocha": true,
7+
"es6": true
8+
},
9+
"parserOptions": {
10+
"ecmaFeatures": {
11+
"modules": true,
12+
"jsx": true
13+
}
14+
},
15+
"rules": {
16+
"no-empty": 0,
17+
"no-console": 0,
18+
"no-unused-vars": [0, { "varsIgnorePattern": "^h$" }],
19+
"no-cond-assign": 1,
20+
"semi": 2,
21+
"camelcase": 0,
22+
"comma-style": 2,
23+
"comma-dangle": [2, "never"],
24+
"indent": [2, "tab", {"SwitchCase": 1}],
25+
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
26+
"no-trailing-spaces": [2, { "skipBlankLines": true }],
27+
"max-nested-callbacks": [2, 3],
28+
"no-eval": 2,
29+
"no-implied-eval": 2,
30+
"no-new-func": 2,
31+
"guard-for-in": 0,
32+
"eqeqeq": [2, "smart"],
33+
"no-else-return": 2,
34+
"no-redeclare": 2,
35+
"no-dupe-keys": 2,
36+
"radix": 2,
37+
"strict": [2, "never"],
38+
"no-shadow": 0,
39+
"no-delete-var": 2,
40+
"no-undef-init": 2,
41+
"no-shadow-restricted-names": 2,
42+
"handle-callback-err": 0,
43+
"no-lonely-if": 2,
44+
"keyword-spacing": 2,
45+
"constructor-super": 2,
46+
"no-this-before-super": 2,
47+
"no-dupe-class-members": 2,
48+
"no-const-assign": 2,
49+
"prefer-spread": 2,
50+
"no-useless-concat": 2,
51+
"no-var": 2,
52+
"object-shorthand": 2,
53+
"prefer-arrow-callback": 2
54+
}
455
}

package.json

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
"version": "2.6.1",
55
"description": "Render JSX to an HTML string, with support for Preact components.",
66
"main": "dist/index.js",
7+
"jsnext:main": "src/index.js",
78
"scripts": {
8-
"build": "babel src -s -d dist --module-id $npm_package_amdName",
9-
"test": "eslint {src,test} && mocha --compilers js:babel/register test/**/*.js",
9+
"build": "rollup -c rollup.config.js -m ${npm_package_main}.map -f umd -n $npm_package_amdName $npm_package_jsnext_main -o $npm_package_main",
10+
"test": "eslint {src,test} && mocha --compilers js:babel-register test/**/*.js",
1011
"prepublish": "npm run build",
1112
"release": "npm run build && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish"
1213
},
@@ -30,12 +31,23 @@
3031
"preact": "*"
3132
},
3233
"devDependencies": {
33-
"babel": "^5.8.23",
34-
"babel-eslint": "^4.1.3",
34+
"babel-cli": "^6.11.4",
35+
"babel-core": "^6.11.4",
36+
"babel-eslint": "^6.1.2",
37+
"babel-plugin-transform-class-properties": "^6.10.2",
38+
"babel-plugin-transform-react-jsx": "^6.8.0",
39+
"babel-preset-es2015": "^6.9.0",
40+
"babel-preset-es2015-minimal": "^2.0.0",
41+
"babel-preset-es2015-minimal-rollup": "^2.0.0",
42+
"babel-preset-stage-0": "^6.5.0",
43+
"babel-register": "^6.9.0",
3544
"chai": "^3.3.0",
36-
"eslint": "^1.7.1",
45+
"eslint": "^3.1.1",
3746
"mocha": "^2.3.3",
38-
"preact": "^4.1.3",
47+
"preact": "^5.5.0",
48+
"rollup": "^0.34.1",
49+
"rollup-plugin-babel": "^2.6.1",
50+
"rollup-plugin-memory": "^1.0.0",
3951
"sinon": "^1.17.1",
4052
"sinon-chai": "^2.8.0"
4153
}

rollup.config.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import fs from 'fs';
2+
import memory from 'rollup-plugin-memory';
3+
import babel from 'rollup-plugin-babel';
4+
5+
let babelRc = JSON.parse(fs.readFileSync('./.babelrc'));
6+
7+
export default {
8+
entry: 'src/index.js',
9+
exports: 'default',
10+
useStrict: false,
11+
external: ['preact'],
12+
plugins: [
13+
memory({
14+
path: 'src/index.js',
15+
contents: "export { default } from './index';"
16+
}),
17+
babel({
18+
babelrc: false,
19+
comments: false,
20+
exclude: 'node_modules/**',
21+
presets: ['es2015-minimal-rollup'].concat(babelRc.presets.slice(1)),
22+
plugins: babelRc.plugins
23+
})
24+
]
25+
};

src/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ renderToString.render = renderToString;
6666
* @param {VNode} vnode JSX VNode to render.
6767
* @param {Object} [context={}] Optionally pass an initial context object through the render path.
6868
*/
69-
renderToString.shallowRender = (vnode, context) => renderToString(vnode, context, SHALLOW);
69+
let shallowRender = (vnode, context) => renderToString(vnode, context, SHALLOW);
7070

7171

7272
/** You can actually skip preact entirely and import this empty Component base class (or not use a base class at all).
@@ -224,3 +224,11 @@ function getFallbackComponentName(component) {
224224
}
225225
return name;
226226
}
227+
renderToString.shallowRender = shallowRender;
228+
229+
230+
export {
231+
renderToString as render,
232+
renderToString,
233+
shallowRender
234+
};

test/pretty.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { render, shallowRender } from '../src';
22
import { h, Component } from 'preact';
3-
import { expect, use } from 'chai';
3+
import chai, { expect } from 'chai';
44
import { spy, match } from 'sinon';
55
import sinonChai from 'sinon-chai';
6-
use(sinonChai);
6+
chai.use(sinonChai);
77

88
describe('pretty', () => {
99
let prettyRender = jsx => render(jsx, {}, { pretty:true });

test/render.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { render, shallowRender } from '../src';
22
import { h, Component } from 'preact';
3-
import { expect, use } from 'chai';
3+
import chai, { expect } from 'chai';
44
import { spy, match } from 'sinon';
55
import sinonChai from 'sinon-chai';
6-
use(sinonChai);
6+
chai.use(sinonChai);
77

88
describe('render', () => {
99
describe('Basic JSX', () => {

test/shallowRender.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { shallowRender } from '../src';
22
import { h, Component } from 'preact';
3-
import { expect, use } from 'chai';
3+
import chai, { expect } from 'chai';
44
import { spy, match } from 'sinon';
55
import sinonChai from 'sinon-chai';
6-
use(sinonChai);
6+
chai.use(sinonChai);
77

88
describe('shallowRender()', () => {
99
it('should not render nested components', () => {

0 commit comments

Comments
 (0)