Skip to content

Commit

Permalink
feat: only esm and correct import paths
Browse files Browse the repository at this point in the history
BREAKING CHANGE: CommonJS module are no longer provided.
BREAKING CHANGE: import paths in ES modules include file name
extensions.
BREAKING CHANGE: Compiled to ES2015 (was ES5).

Fixes #516.
Fixes #437.
Fixes #263. Kind of. Because there is no build step.

Thanks to @mreinstein on starting this work.
  • Loading branch information
mightyiam committed May 11, 2020
1 parent a42c31a commit 8248bbb
Show file tree
Hide file tree
Showing 24 changed files with 1,556 additions and 2,884 deletions.
3 changes: 0 additions & 3 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
module.exports = {
extends: 'standard-with-typescript',
parserOptions: { project: [ './tsconfig.json', ] },
ignorePatterns: [
'/examples/**/build.js'
],
rules: {
'import/newline-after-import': 'error',
'max-statements-per-line': 'error',
Expand Down
64 changes: 0 additions & 64 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,67 +68,3 @@
/es/vnode.d.ts
/es/vnode.js
/es/vnode.js.map

# Built CommonJS modules
/helpers/attachto.d.ts
/helpers/attachto.js
/helpers/attachto.js.map
/modules/attributes.d.ts
/modules/attributes.js
/modules/attributes.js.map
/modules/class.d.ts
/modules/class.js
/modules/class.js.map
/modules/dataset.d.ts
/modules/dataset.js
/modules/dataset.js.map
/modules/eventlisteners.d.ts
/modules/eventlisteners.js
/modules/eventlisteners.js.map
/modules/hero.d.ts
/modules/hero.js
/modules/hero.js.map
/modules/module.d.ts
/modules/module.js
/modules/module.js.map
/modules/props.d.ts
/modules/props.js
/modules/props.js.map
/modules/style.d.ts
/modules/style.js
/modules/style.js.map
/benchmark/
/test/
/h.d.ts
/h.js
/h.js.map
/hooks.d.ts
/hooks.js
/hooks.js.map
/htmldomapi.d.ts
/htmldomapi.js
/htmldomapi.js.map
/is.d.ts
/is.js
/is.js.map
/jsx-global.d.ts
/jsx-global.js
/jsx-global.js.map
/jsx.d.ts
/jsx.js
/jsx.js.map
/snabbdom.bundle.d.ts
/snabbdom.bundle.js
/snabbdom.bundle.js.map
/snabbdom.d.ts
/snabbdom.js
/snabbdom.js.map
/thunk.d.ts
/thunk.js
/thunk.js.map
/tovnode.d.ts
/tovnode.js
/tovnode.js.map
/vnode.d.ts
/vnode.js
/vnode.js.map
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: node_js
node_js:
- v12.10.0
script:
- commitlint-travis
- commitlint-travis -x @commitlint/config-conventional
- run-s test docs check-clean
env:
global:
Expand Down
50 changes: 30 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,20 @@ performance, small size and all the features listed below.
## Example

```javascript
var snabbdom = require('snabbdom');
var patch = snabbdom.init([ // Init patch function with chosen modules
require('snabbdom/modules/class').default, // makes it easy to toggle classes
require('snabbdom/modules/props').default, // for setting properties on DOM elements
require('snabbdom/modules/style').default, // handles styling on elements with support for animations
require('snabbdom/modules/eventlisteners').default, // attaches event listeners
import { init } from 'snabbdom';
import clazz from 'snabbdom/class';
import h from 'snabbdom/h';
import props from 'snabbdom/props';
import style from 'snabbdom/style';
import listeners from 'snabbdom/eventlisteners';

var patch = init([ // Init patch function with chosen modules
clazz, // makes it easy to toggle classes
props, // for setting properties on DOM elements
style, // handles styling on elements with support for animations
listeners, // attaches event listeners
]);
var h = require('snabbdom/h').default; // helper function for creating vnodes
import h from 'snabbdom/h'; // helper function for creating vnodes

var container = document.getElementById('container');

Expand Down Expand Up @@ -150,10 +156,10 @@ takes a list of modules and returns a `patch` function that uses the
specified set of modules.

```javascript
var patch = snabbdom.init([
require('snabbdom/modules/class').default,
require('snabbdom/modules/style').default,
]);
import clazz from 'snabbdom/class';
import style from 'snabbdom/style';

var patch = init([ clazz, style ]);
```

### `patch`
Expand Down Expand Up @@ -194,7 +200,7 @@ tag/selector as a string, an optional data object and an optional string or
array of children.

```javascript
var h = require('snabbdom/h').default;
import h from 'snabbdom/h';
var vnode = h('div', {style: {color: '#000'}}, [
h('h1', 'Headline'),
h('p', 'A paragraph'),
Expand All @@ -207,15 +213,19 @@ Converts a DOM node into a virtual node. Especially good for patching over an pr
server-side generated content.

```javascript
var snabbdom = require('snabbdom')
var patch = snabbdom.init([ // Init patch function with chosen modules
require('snabbdom/modules/class').default, // makes it easy to toggle classes
require('snabbdom/modules/props').default, // for setting properties on DOM elements
require('snabbdom/modules/style').default, // handles styling on elements with support for animations
require('snabbdom/modules/eventlisteners').default, // attaches event listeners
import { init } from 'snabbdom';
import clazz from 'snabbdom/class';
import props from 'snabbdom/props';
import style from 'snabbdom/style';
import listeners from 'snabbdom/eventlisteners';
var patch = init([ // Init patch function with chosen modules
clazz, // makes it easy to toggle classes
props, // for setting properties on DOM elements
style, // handles styling on elements with support for animations
listeners, // attaches event listeners
]);
var h = require('snabbdom/h').default; // helper function for creating vnodes
var toVNode = require('snabbdom/tovnode').default;
import h from 'snabbdom/h'; // helper function for creating vnodes
import toVNode from 'snabbdom/tovnode';

var newVNode = h('div', {style: {color: '#000'}}, [
h('h1', 'Headline'),
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion commitlint.config.js

This file was deleted.

16 changes: 0 additions & 16 deletions examples/carousel-svg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,4 @@ This carousel example uses `style transform` and `transition` to rotate a group

Also, the color of each triangle changes when you hover or click/tap it.

I built the build.js using npm and browserify.

In my local copy of the snabbdom project root I did these preparations:

```sh
npm install --save-dev babelify
npm install --save-dev babel-preset-es2015
echo '{ "presets": ["es2015"] }' > .babelrc
```

I then built like this:

```sh
browserify examples/carousel-svg/script.js -t babelify -o examples/carousel-svg/build.js
```

\-- _jk_
Loading

0 comments on commit 8248bbb

Please sign in to comment.