Skip to content

Commit

Permalink
chore: Change the module to use a named export for Editable
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The module exports changed from a default export to a named export

For Import:
change
```
import Editable from '@livingdocs/editable.js'
```
to
```
import {Editable} from '@livingdocs/editable.js'
```

For require:
change
```
const Editable = require('@livingdocs/editable.js')
```
to
```
const {Editable} = require('@livingdocs/editable.js')
```

The source code doesn't get transpiled anymore into the `lib` directory.
This simplifies the usage together with npm link as there's a build step less in between.

The files in the dist folder should work as before.
  • Loading branch information
marcbachmann committed Aug 2, 2021
1 parent ed5a4fe commit 58f9a24
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Prism from 'prismjs'

import Editable from '../src/core'
import {Editable} from '../src/core'
import eventList from './events.js'

// Paragraph Example
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"editable"
],
"license": "MIT",
"main": "lib/core.js",
"module": "src/core.js",
"repository": {
"type": "git",
"url": "https://github.com/livingdocsIO/editable.js.git"
Expand All @@ -67,8 +67,7 @@
"start": "WEBPACK_DEV=true BUILD_DOCS=true webpack serve",
"build:dist": "rimraf ./coverage && BUILD_DIST=true webpack",
"build:docs": "rimraf ./examples/dist && BUILD_DOCS=true webpack",
"build:lib": "rimraf ./{lib,coverage} && babel src --out-dir lib",
"build": "npm run build:dist -s && npm run build:lib -s && npm run build:docs -s",
"build": "npm run build:dist -s && npm run build:docs -s",
"test:ci": "npm run test:karma -s",
"test": "npm run build -s && npm run test:karma -s",
"posttest": "npm run lint -s",
Expand Down
2 changes: 1 addition & 1 deletion spec/api.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Editable from '../src/core'
import {Editable} from '../src/core'

describe('Editable', function () {
let editable, div
Expand Down
2 changes: 1 addition & 1 deletion spec/config.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cloneDeep from 'lodash.clonedeep'
import config from '../src/config'
import Editable from '../src/core'
import {Editable} from '../src/core'

describe('Editable configuration', function () {

Expand Down
2 changes: 1 addition & 1 deletion spec/create-default-events.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import rangy from 'rangy'

import Cursor from '../src/cursor'
import Editable from '../src/core'
import {Editable} from '../src/core'

describe('Default Events', function () {

Expand Down
2 changes: 1 addition & 1 deletion spec/dispatcher.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import rangy from 'rangy'
import * as content from '../src/content'
import Cursor from '../src/cursor'
import Keyboard from '../src/keyboard'
import Editable from '../src/core'
import {Editable} from '../src/core'
import Selection from '../src/selection'
const {key} = Keyboard

Expand Down
2 changes: 1 addition & 1 deletion spec/highlighting.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import rangy from 'rangy'
import Editable from '../src/core'
import {Editable} from '../src/core'
import Highlighting from '../src/highlighting'
import highlightSupport from '../src/highlight-support'
import WordHighlighter from '../src/plugins/highlighting/text-highlighting'
Expand Down
2 changes: 1 addition & 1 deletion spec/spellcheck.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import rangy from 'rangy'
import sinon from 'sinon'

import Editable from '../src/core'
import {Editable} from '../src/core'
import Highlighting from '../src/highlighting'
import Cursor from '../src/cursor'
import {createElement} from '../src/util/dom'
Expand Down
2 changes: 1 addition & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {domArray} from './util/dom'
*
* @class Editable
*/
export default class Editable {
export class Editable {

constructor (instanceConfig) {
const defaultInstanceConfig = {
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = {
output: {
library: dist ? 'Editable' : undefined,
libraryTarget: 'umd',
libraryExport: 'default',
libraryExport: 'Editable',
path: __dirname,
filename: '[name].js'
},
Expand Down

0 comments on commit 58f9a24

Please sign in to comment.