Skip to content

Commit

Permalink
ux(exports): replaced main export path with init
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The main export path, 'snabbdom' was replaced with
the export path 'snabbdom/init'. This new export path includes only
the named export `init`.

Reference: #522.
  • Loading branch information
mightyiam committed Jun 18, 2020
1 parent fefd141 commit 09f2d1c
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
/build/package/htmldomapi.d.ts
/build/package/htmldomapi.js
/build/package/htmldomapi.js.map
/build/package/init.d.ts
/build/package/init.js
/build/package/init.js.map
/build/package/is.d.ts
/build/package/is.js
/build/package/is.js.map
Expand Down Expand Up @@ -56,9 +59,6 @@
/build/package/modules/style.d.ts
/build/package/modules/style.js
/build/package/modules/style.js.map
/build/package/snabbdom.d.ts
/build/package/snabbdom.js
/build/package/snabbdom.js.map
/build/package/thunk.d.ts
/build/package/thunk.js
/build/package/thunk.js.map
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ performance, small size and all the features listed below.
## Example

```mjs
import { init } from 'snabbdom'
import { init } from 'snabbdom/init'
import { classModule } from 'snabbdom/modules/class'
import { propsModule } from 'snabbdom/modules/props'
import { styleModule } from 'snabbdom/modules/style'
Expand Down Expand Up @@ -102,7 +102,7 @@ patch(vnode, newVnode) // Snabbdom efficiently updates the old view to the new s
## Table of contents

* [Core documentation](#core-documentation)
* [`snabbdom.init`](#snabbdominit)
* [`init`](#init)
* [`patch`](#patch)
* [Unmounting](#unmounting)
* [`snabbdom/h`](#snabbdomh)
Expand Down Expand Up @@ -146,9 +146,9 @@ The core of Snabbdom provides only the most essential functionality.
It is designed to be as simple as possible while still being fast and
extendable.

### `snabbdom.init`
### `init`

The core exposes only one single function `snabbdom.init`. This `init`
The core exposes only one single function `init`. This `init`
takes a list of modules and returns a `patch` function that uses the
specified set of modules.

Expand Down Expand Up @@ -211,7 +211,7 @@ Converts a DOM node into a virtual node. Especially good for patching over an pr
server-side generated content.

```mjs
import { init } from 'snabbdom'
import { init } from 'snabbdom/init'
import { classModule } from 'snabbdom/modules/class'
import { propsModule } from 'snabbdom/modules/props'
import { styleModule } from 'snabbdom/modules/style'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "A virtual DOM library with focus on simplicity, modularity, powerful features and performance.",
"type": "module",
"exports": {
"./": "./build/package/snabbdom.js",
"./init": "./build/package/init.js",
"./h": "./build/package/h.js",
"./helpers/attachto": "./build/package/helpers/attachto.js",
"./hooks": "./build/package/hooks.js",
Expand Down
3 changes: 0 additions & 3 deletions src/package/snabbdom.ts → src/package/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ function createKeyToOldIdx (children: VNode[], beginIdx: number, endIdx: number)

const hooks: Array<keyof Module> = ['create', 'update', 'remove', 'destroy', 'pre', 'post']

export { h } from './h'
export { thunk } from './thunk'

export function init (modules: Array<Partial<Module>>, domApi?: DOMAPI) {
let i: number
let j: number
Expand Down
2 changes: 1 addition & 1 deletion src/package/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"helpers/attachto.ts",
"hooks.ts",
"htmldomapi.ts",
"init.ts",
"is.ts",
"jsx-global.ts",
"jsx.ts",
Expand All @@ -33,7 +34,6 @@
"modules/module.ts",
"modules/props.ts",
"modules/style.ts",
"snabbdom.ts",
"thunk.ts",
"tovnode.ts",
"vnode.ts"
Expand Down
2 changes: 1 addition & 1 deletion src/test/benchmark/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'core-js/stable/array/fill'
import faker from 'faker'
import { VNode } from '../../package/vnode'
import { h } from '../../package/h'
import { init as curInit } from '../../package/snabbdom'
import { init as curInit } from '../../package/init'
import { init as refInit } from 'latest-snabbdom-release'
import { assert } from 'chai'
import pReduce from 'p-reduce'
Expand Down
2 changes: 1 addition & 1 deletion src/test/unit/attachto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert } from 'chai'
import { init } from '../../package/snabbdom'
import { init } from '../../package/init'
import { RemoveHook } from '../../package/hooks'
import { attachTo } from '../../package/helpers/attachto'
import { h } from '../../package/h'
Expand Down
2 changes: 1 addition & 1 deletion src/test/unit/attributes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert } from 'chai'
import { init } from '../../package/snabbdom'
import { init } from '../../package/init'
import { attributesModule } from '../../package/modules/attributes'
import { h } from '../../package/h'

Expand Down
2 changes: 1 addition & 1 deletion src/test/unit/core.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai'
import shuffle from 'lodash.shuffle'

import { init } from '../../package/snabbdom'
import { init } from '../../package/init'
import { classModule } from '../../package/modules/class'
import { propsModule } from '../../package/modules/props'
import { styleModule } from '../../package/modules/style'
Expand Down
2 changes: 1 addition & 1 deletion src/test/unit/dataset.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai'

import { datasetModule } from '../../package/modules/dataset'
import { init } from '../../package/snabbdom'
import { init } from '../../package/init'
import { h } from '../../package/h'

var patch = init([
Expand Down
2 changes: 1 addition & 1 deletion src/test/unit/eventlisteners.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai'
import { VNode } from '../../package/vnode'

import { init } from '../../package/snabbdom'
import { init } from '../../package/init'
import { eventListenersModule } from '../../package/modules/eventlisteners'
import { h } from '../../package/h'

Expand Down
2 changes: 1 addition & 1 deletion src/test/unit/htmldomapi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert } from 'chai'

import { init } from '../../package/snabbdom'
import { init } from '../../package/init'
import { h } from '../../package/h'
import { attributesModule } from '../../package/modules/attributes'

Expand Down
2 changes: 1 addition & 1 deletion src/test/unit/style.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert } from 'chai'

import { init } from '../../package/snabbdom'
import { init } from '../../package/init'
import { styleModule } from '../../package/modules/style'
import { h } from '../../package/h'
import { toVNode } from '../../package/tovnode'
Expand Down
2 changes: 1 addition & 1 deletion src/test/unit/thunk.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert } from 'chai'

import { init } from '../../package/snabbdom'
import { init } from '../../package/init'
import { h } from '../../package/h'
import { thunk } from '../../package/thunk'
import { VNode } from '../../package/vnode'
Expand Down

0 comments on commit 09f2d1c

Please sign in to comment.