Skip to content

Commit

Permalink
use conditional exports pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
dmonad committed May 18, 2021
1 parent 8a70262 commit 255b7e6
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 78 deletions.
4 changes: 2 additions & 2 deletions auth.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import * as Y from 'yjs' // eslint-disable-line
import * as encoding from 'lib0/encoding.js'
import * as decoding from 'lib0/decoding.js'
import * as encoding from 'lib0/encoding'
import * as decoding from 'lib0/decoding'

export const messagePermissionDenied = 0

Expand Down
12 changes: 6 additions & 6 deletions awareness.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
* @module awareness-protocol
*/

import * as encoding from 'lib0/encoding.js'
import * as decoding from 'lib0/decoding.js'
import * as time from 'lib0/time.js'
import * as math from 'lib0/math.js'
import { Observable } from 'lib0/observable.js'
import * as f from 'lib0/function.js'
import * as encoding from 'lib0/encoding'
import * as decoding from 'lib0/decoding'
import * as time from 'lib0/time'
import * as math from 'lib0/math'
import { Observable } from 'lib0/observable'
import * as f from 'lib0/function'
import * as Y from 'yjs' // eslint-disable-line

export const outdatedTimeout = 30000
Expand Down
4 changes: 2 additions & 2 deletions awareness.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import * as Y from 'yjs'
import * as t from 'lib0/testing.js'
import * as awareness from './awareness.js'
import * as t from 'lib0/testing'
import * as awareness from './awareness'

/**
* @param {t.TestCase} tc
Expand Down
106 changes: 50 additions & 56 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 27 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,38 @@
"url": "https://github.com/yjs/y-protocols/issues"
},
"homepage": "https://github.com/yjs/y-protocols#readme",
"exports": {
"./package.json": "./package.json",
"./sync.js": "./sync.js",
"./dist/sync.cjs": "./dist/sync.cjs",
"./sync": {
"import": "./sync.js",
"require": "./dist/sync.cjs"
},
"./awareness.js": "./awareness.js",
"./dist/awareness.cjs": "./dist/awareness.cjs",
"./awareness": {
"import": "./awareness.js",
"require": "./dist/awareness.cjs"
},
"./auth.js": "./auth.js",
"./dist/auth.cjs": "./dist/auth.cjs",
"./auth": {
"import": "./auth.js",
"require": "./dist/auth.cjs"
}
},
"dependencies": {
"lib0": "^0.2.35"
"lib0": "^0.2.42"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.1",
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-node-resolve": "^11.2.1",
"concurrently": "^5.3.0",
"rollup": "^2.30.0",
"rollup": "^2.48.0",
"standard": "^12.0.1",
"typescript": "^4.1.3",
"yjs": "^13.4.9"
"typescript": "^4.2.4",
"yjs": "^13.5.6"
},
"peerDependenies": {
"yjs": "^13.0.0"
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default [{
chunkFileNames: '[name]-[hash].cjs',
paths: /** @param {any} path */ path => {
if (/^lib0\//.test(path)) {
return `lib0/dist/${path.slice(5, -3) + '.cjs'}`
return `lib0/dist/${path.slice(5) + '.cjs'}`
}
return path
}
Expand Down
4 changes: 2 additions & 2 deletions sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @module sync-protocol
*/

import * as encoding from 'lib0/encoding.js'
import * as decoding from 'lib0/decoding.js'
import * as encoding from 'lib0/encoding'
import * as decoding from 'lib0/decoding'
import * as Y from 'yjs'

/**
Expand Down
6 changes: 3 additions & 3 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { runTests } from 'lib0/testing.js'
import * as log from 'lib0/logging.js'
import { runTests } from 'lib0/testing'
import * as log from 'lib0/logging'
import * as awareness from './awareness.test.js'

import { isBrowser, isNode } from 'lib0/environment.js'
import { isBrowser, isNode } from 'lib0/environment'

/* istanbul ignore if */
if (isBrowser) {
Expand Down

0 comments on commit 255b7e6

Please sign in to comment.