From 62888b40042d4216cf46cd11d93d783d4aadafcc Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Wed, 12 Feb 2020 10:37:22 +0100 Subject: [PATCH] bundle yjs as a module to prevent declaration issues from circular dependencies --- package.json | 2 +- rollup.config.js | 15 +++++++++++++++ src/index.js | 3 ++- src/utils/Transaction.js | 1 - 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index ab741292..1fc16c4a 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "13.0.2", "description": "Shared Editing Library", "main": "./dist/yjs.cjs", - "module": "./src/index.js", + "module": "./dist/yjs.mjs", "types": "./dist/src/index.d.ts", "sideEffects": false, "scripts": { diff --git a/rollup.config.js b/rollup.config.js index 9fe1eece..34fcd3e8 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -51,6 +51,21 @@ export default [{ } }, external: id => /^lib0\//.test(id) +}, { + input: './src/index.js', + output: { + name: 'Y', + file: 'dist/yjs.mjs', + format: 'esm', + sourcemap: true, + paths: path => { + if (/^lib0\//.test(path)) { + return `lib0/dist/${path.slice(5, -3)}.cjs` + } + return path + } + }, + external: id => /^lib0\//.test(id) }, { input: './tests/index.js', output: { diff --git a/src/index.js b/src/index.js index d8c59511..2973dfb8 100644 --- a/src/index.js +++ b/src/index.js @@ -56,5 +56,6 @@ export { isParentOf, equalSnapshots, PermanentUserData, // @TODO experimental - tryGc + tryGc, + transact } from './internals.js' diff --git a/src/utils/Transaction.js b/src/utils/Transaction.js index fd312000..3f0e2f8a 100644 --- a/src/utils/Transaction.js +++ b/src/utils/Transaction.js @@ -338,7 +338,6 @@ const cleanupTransactions = (transactionCleanups, i) => { * @param {function(Transaction):void} f * @param {any} [origin=true] * - * @private * @function */ export const transact = (doc, f, origin = null, local = true) => {