From aa69dd5d9a101922527736cebee602135f23d53e Mon Sep 17 00:00:00 2001 From: Julien Martel Date: Fri, 18 Oct 2024 10:36:34 -0500 Subject: [PATCH 1/4] add amd build --- rollup.config.js | 185 ++++++++++++++++++++++++++--------------------- 1 file changed, 104 insertions(+), 81 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index 61afb735e..5a10d15bc 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,106 +1,129 @@ -import nodeResolve from '@rollup/plugin-node-resolve' -import commonjs from '@rollup/plugin-commonjs' +import nodeResolve from "@rollup/plugin-node-resolve" +import commonjs from "@rollup/plugin-commonjs" const localImports = process.env.LOCALIMPORTS const customModules = new Set([ - 'y-websocket', - 'y-codemirror', - 'y-ace', - 'y-textarea', - 'y-quill', - 'y-dom', - 'y-prosemirror' + "y-websocket", + "y-codemirror", + "y-ace", + "y-textarea", + "y-quill", + "y-dom", + "y-prosemirror", ]) /** * @type {Set} */ -const customLibModules = new Set([ - 'lib0', - 'y-protocols' -]) +const customLibModules = new Set(["lib0", "y-protocols"]) const debugResolve = { - resolveId (importee) { - if (importee === 'yjs') { + resolveId(importee) { + if (importee === "yjs") { return `${process.cwd()}/src/index.js` } if (localImports) { - if (customModules.has(importee.split('/')[0])) { + if (customModules.has(importee.split("/")[0])) { return `${process.cwd()}/../${importee}/src/${importee}.js` } - if (customLibModules.has(importee.split('/')[0])) { + if (customLibModules.has(importee.split("/")[0])) { return `${process.cwd()}/../${importee}` } } return null - } + }, } -export default [{ - input: './src/index.js', - output: { - name: 'Y', - file: 'dist/yjs.cjs', - format: 'cjs', - sourcemap: true +export default [ + { + input: "./src/index.js", + output: { + name: "Y", + file: "dist/yjs.cjs", + format: "cjs", + sourcemap: true, + }, + external: (id) => /^lib0\//.test(id), }, - external: id => /^lib0\//.test(id) -}, { - input: './src/index.js', - output: { - name: 'Y', - file: 'dist/yjs.mjs', - format: 'esm', - sourcemap: true + { + input: "./src/index.js", + output: { + name: "Y", + file: "dist/yjs.mjs", + format: "esm", + sourcemap: true, + }, + external: (id) => /^lib0\//.test(id), }, - external: id => /^lib0\//.test(id) -}, { - input: './tests/testHelper.js', - output: { - name: 'Y', - file: 'dist/testHelper.mjs', - format: 'esm', - sourcemap: true + { + input: "./src/index.js", + output: { + name: "Y", + file: "dist/yjs.amd.js", + format: "amd", + sourcemap: true, + }, + plugins: [ + nodeResolve({ + browser: true, // Use browser-compatible versions of modules + extensions: [".js", ".ts"], + preferBuiltins: false, // Do not prefer Node.js built-ins + }), + commonjs(), + // terser, etc. + ], }, - external: id => /^lib0\//.test(id) || id === 'yjs', - plugins: [{ - resolveId (importee) { - if (importee === '../src/index.js') { - return 'yjs' - } - return null - } - }] -}, { - input: './tests/index.js', - output: { - name: 'test', - file: 'dist/tests.js', - format: 'iife', - sourcemap: true + { + input: "./tests/testHelper.js", + output: { + name: "Y", + file: "dist/testHelper.mjs", + format: "esm", + sourcemap: true, + }, + external: (id) => /^lib0\//.test(id) || id === "yjs", + plugins: [ + { + resolveId(importee) { + if (importee === "../src/index.js") { + return "yjs" + } + return null + }, + }, + ], + }, + { + input: "./tests/index.js", + output: { + name: "test", + file: "dist/tests.js", + format: "iife", + sourcemap: true, + }, + plugins: [ + debugResolve, + nodeResolve({ + mainFields: ["browser", "module", "main"], + }), + commonjs(), + ], }, - plugins: [ - debugResolve, - nodeResolve({ - mainFields: ['browser', 'module', 'main'] - }), - commonjs() - ] -}, { - input: './tests/index.js', - output: { - name: 'test', - file: 'dist/tests.cjs', - format: 'cjs', - sourcemap: true + { + input: "./tests/index.js", + output: { + name: "test", + file: "dist/tests.cjs", + format: "cjs", + sourcemap: true, + }, + plugins: [ + debugResolve, + nodeResolve({ + mainFields: ["node", "module", "main"], + exportConditions: ["node", "module", "import", "default"], + }), + commonjs(), + ], + external: (id) => /^lib0\//.test(id), }, - plugins: [ - debugResolve, - nodeResolve({ - mainFields: ['node', 'module', 'main'], - exportConditions: ['node', 'module', 'import', 'default'] - }), - commonjs() - ], - external: id => /^lib0\//.test(id) -}] +] From 957288e9fdede4befd2768843d97d339d9081388 Mon Sep 17 00:00:00 2001 From: Leonardo Ortiz Date: Wed, 23 Oct 2024 12:38:02 -0300 Subject: [PATCH 2/4] main file as amd --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4beb88f25..887d6bd85 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "yjs", "version": "13.6.20", "description": "Shared Editing Library", - "main": "./dist/yjs.cjs", + "main": "./dist/yjs.amd.js", "module": "./dist/yjs.mjs", "types": "./dist/src/index.d.ts", "type": "module", @@ -96,4 +96,4 @@ "npm": ">=8.0.0", "node": ">=16.0.0" } -} +} \ No newline at end of file From d0c22b1a3c81bed77ec927c62a60250a91cb9363 Mon Sep 17 00:00:00 2001 From: Leonardo Ortiz Date: Fri, 1 Nov 2024 17:04:41 -0300 Subject: [PATCH 3/4] update name and repo url --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 887d6bd85..24de0a4e5 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "yjs", + "name": "yjs-amd", "version": "13.6.20", "description": "Shared Editing Library", "main": "./dist/yjs.amd.js", @@ -57,7 +57,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/yjs/yjs.git" + "url": "https://github.com/monogramdesign/yjs.git" }, "keywords": [ "Yjs", From 7457fb3e41781a4937f9914260189b879511acbd Mon Sep 17 00:00:00 2001 From: Leonardo Ortiz Date: Mon, 4 Nov 2024 10:49:52 -0300 Subject: [PATCH 4/4] undo formatting changes in rollup config --- rollup.config.js | 199 +++++++++++++++++++++++------------------------ 1 file changed, 96 insertions(+), 103 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index 5a10d15bc..eb134961b 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,129 +1,122 @@ -import nodeResolve from "@rollup/plugin-node-resolve" -import commonjs from "@rollup/plugin-commonjs" +import nodeResolve from '@rollup/plugin-node-resolve' +import commonjs from '@rollup/plugin-commonjs' const localImports = process.env.LOCALIMPORTS const customModules = new Set([ - "y-websocket", - "y-codemirror", - "y-ace", - "y-textarea", - "y-quill", - "y-dom", - "y-prosemirror", + 'y-websocket', + 'y-codemirror', + 'y-ace', + 'y-textarea', + 'y-quill', + 'y-dom', + 'y-prosemirror' ]) /** * @type {Set} */ -const customLibModules = new Set(["lib0", "y-protocols"]) +const customLibModules = new Set([ + 'lib0', + 'y-protocols' +]) const debugResolve = { - resolveId(importee) { - if (importee === "yjs") { + resolveId (importee) { + if (importee === 'yjs') { return `${process.cwd()}/src/index.js` } if (localImports) { - if (customModules.has(importee.split("/")[0])) { + if (customModules.has(importee.split('/')[0])) { return `${process.cwd()}/../${importee}/src/${importee}.js` } - if (customLibModules.has(importee.split("/")[0])) { + if (customLibModules.has(importee.split('/')[0])) { return `${process.cwd()}/../${importee}` } } return null - }, + } } -export default [ - { - input: "./src/index.js", - output: { - name: "Y", - file: "dist/yjs.cjs", - format: "cjs", - sourcemap: true, - }, - external: (id) => /^lib0\//.test(id), +export default [{ + input: './src/index.js', + output: { + name: 'Y', + file: 'dist/yjs.cjs', + format: 'cjs', + sourcemap: true }, - { - input: "./src/index.js", - output: { - name: "Y", - file: "dist/yjs.mjs", - format: "esm", - sourcemap: true, - }, - external: (id) => /^lib0\//.test(id), + external: id => /^lib0\//.test(id) +}, { + input: './src/index.js', + output: { + name: 'Y', + file: 'dist/yjs.mjs', + format: 'esm', + sourcemap: true }, - { - input: "./src/index.js", - output: { - name: "Y", - file: "dist/yjs.amd.js", - format: "amd", - sourcemap: true, - }, - plugins: [ - nodeResolve({ - browser: true, // Use browser-compatible versions of modules - extensions: [".js", ".ts"], - preferBuiltins: false, // Do not prefer Node.js built-ins - }), - commonjs(), - // terser, etc. - ], + external: id => /^lib0\//.test(id) +}, { + input: './tests/testHelper.js', + output: { + name: 'Y', + file: 'dist/testHelper.mjs', + format: 'esm', + sourcemap: true }, - { - input: "./tests/testHelper.js", - output: { - name: "Y", - file: "dist/testHelper.mjs", - format: "esm", - sourcemap: true, - }, - external: (id) => /^lib0\//.test(id) || id === "yjs", - plugins: [ - { - resolveId(importee) { - if (importee === "../src/index.js") { - return "yjs" - } - return null - }, - }, - ], + external: id => /^lib0\//.test(id) || id === 'yjs', + plugins: [{ + resolveId (importee) { + if (importee === '../src/index.js') { + return 'yjs' + } + return null + } + }] +}, { + input: './tests/index.js', + output: { + name: 'test', + file: 'dist/tests.js', + format: 'iife', + sourcemap: true }, - { - input: "./tests/index.js", - output: { - name: "test", - file: "dist/tests.js", - format: "iife", - sourcemap: true, - }, - plugins: [ - debugResolve, - nodeResolve({ - mainFields: ["browser", "module", "main"], - }), - commonjs(), - ], + plugins: [ + debugResolve, + nodeResolve({ + mainFields: ['browser', 'module', 'main'] + }), + commonjs() + ] +}, { + input: './tests/index.js', + output: { + name: 'test', + file: 'dist/tests.cjs', + format: 'cjs', + sourcemap: true }, - { - input: "./tests/index.js", - output: { - name: "test", - file: "dist/tests.cjs", - format: "cjs", - sourcemap: true, - }, - plugins: [ - debugResolve, - nodeResolve({ - mainFields: ["node", "module", "main"], - exportConditions: ["node", "module", "import", "default"], - }), - commonjs(), - ], - external: (id) => /^lib0\//.test(id), + plugins: [ + debugResolve, + nodeResolve({ + mainFields: ['node', 'module', 'main'], + exportConditions: ['node', 'module', 'import', 'default'] + }), + commonjs() + ], + external: id => /^lib0\//.test(id) +}, { + input: './src/index.js', + output: { + name: 'Y', + file: 'dist/yjs.amd.js', + format: 'amd', + sourcemap: true }, -] + plugins: [ + nodeResolve({ + browser: true, // Use browser-compatible versions of modules + extensions: ['.js', '.ts'], + preferBuiltins: false // Do not prefer Node.js built-ins + }), + commonjs() + ] +}] \ No newline at end of file