Skip to content

Commit

Permalink
update dependencies and make this an esm module
Browse files Browse the repository at this point in the history
  • Loading branch information
dmonad committed Jan 7, 2022
1 parent 56e3289 commit ae2d46d
Show file tree
Hide file tree
Showing 7 changed files with 1,580 additions and 2,645 deletions.
4,091 changes: 1,530 additions & 2,561 deletions package-lock.json

Large diffs are not rendered by default.

43 changes: 25 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
"name": "y-monaco",
"version": "0.1.2",
"description": "Monaco editor bindings for Yjs",
"main": "./dist/y-monaco.js",
"main": "./src/y-monaco.js",
"module": "./src/y-monaco.js",
"type": "module",
"sideEffects": false,
"scripts": {
"start": "npm run demo",
"demo": "webpack-dev-server --open-page .",
"dist": "npm run clean && rollup -c",
"test": "rollup -c && node test/test.node.js",
"test": "rollup -c && node test/test.node.cjs",
"lint": "standard",
"watch": "rollup -wc",
"debug": "concurrently 'live-server --port=3443 --entry-file=test.html' 'npm run watch'",
Expand All @@ -20,6 +21,13 @@
"dist/*",
"src/*"
],
"exports": {
".": {
"import": "./src/y-monaco.js",
"require": "./dist/y-monaco.cjs"
},
"./package.json": "./package.json"
},
"repository": {
"type": "git",
"url": "git+https://github.com/y-js/y-monaco.git"
Expand All @@ -35,33 +43,32 @@
},
"homepage": "https://github.com/y-js/y-monaco#readme",
"dependencies": {
"lib0": "^0.2.35"
"lib0": "^0.2.43"
},
"peerDependencies": {
"yjs": "^13.3.1 && >=13.3.1",
"y-protocols": ">=1.0.1",
"yjs": "^13.3.1",
"monaco-editor": ">=0.20.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^14.0.0",
"@rollup/plugin-node-resolve": "^8.4.0",
"@types/node": "^12.19.12",
"concurrently": "^5.3.0",
"css-loader": "^4.3.0",
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-node-resolve": "^13.1.3",
"@types/node": "^12.20.41",
"css-loader": "^6.5.1",
"file-loader": "^6.2.0",
"concurrently": "^5.3.0",
"jsdom": "^15.2.1",
"live-server": "^1.2.1",
"monaco-editor": "^0.21.2",
"monaco-editor": "^0.21.3",
"monaco-editor-webpack-plugin": "^2.1.0",
"rollup": "^2.36.1",
"rollup-plugin-postcss": "^3.1.8",
"rollup": "^2.63.0",
"rollup-plugin-postcss": "^4.0.2",
"standard": "^14.3.4",
"style-loader": "^1.3.0",
"webpack": "^4.44.2",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.1",
"y-protocols": "^1.0.2",
"y-websocket": "^1.3.9",
"yjs": "^13.4.9"
"webpack-dev-server": "^3.11.3",
"y-protocols": "^1.0.5",
"y-websocket": "^1.3.18",
"yjs": "^13.5.23"
}
}
73 changes: 16 additions & 57 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,18 @@
import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
// import commonjs from '@rollup/plugin-commonjs'
import postcss from 'rollup-plugin-postcss'
import fs from 'fs'
import path from 'path'

const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, './package.json'), { encoding: 'utf8' }))
const dependencies = Object.keys(pkg.peerDependencies).concat(Object.keys(pkg.dependencies))

const customModules = new Set([
'y-websocket',
'y-codemirror',
'y-ace',
'y-textarea',
'y-quill',
'y-dom',
'y-prosemirror'
])
/**
* @type {Set<any>}
*/
const customLibModules = new Set([
'lib0',
'y-protocols'
])
const debugResolve = {
resolveId (importee) {
if (importee === 'yjs/tests/testHelper.js') {
return `${process.cwd()}/../yjs/tests/testHelper.js`
}
if (importee === 'yjs') {
return `${process.cwd()}/../yjs/src/index.js`
}
if (importee === 'y-monaco') {
return `${process.cwd()}/src/y-monaco.js`
}
if (customModules.has(importee.split('/')[0])) {
return `${process.cwd()}/../${importee}/src/${importee}.js`
}
if (customLibModules.has(importee.split('/')[0])) {
return `${process.cwd()}/../${importee}`
}
if (importee === 'monaco-editor') {
return `${process.cwd()}/node_modules/monaco-editor/esm/vs/editor/editor.api.js`
}
return null
}
}

export default [{
input: './src/y-monaco.js',
output: [{
name: 'Y',
file: 'dist/y-monaco.js',
file: 'dist/y-monaco.cjs',
format: 'cjs',
sourcemap: true,
paths: path => {
if (/^lib0\//.test(path)) {
return `lib0/dist/${path.slice(5)}`
}
return path
}
sourcemap: true
}],
external: id => dependencies.some(dep => dep === id) || /^lib0\//.test(id)
}, {
Expand All @@ -68,25 +21,31 @@ export default [{
name: 'test',
file: 'dist/test.cjs',
format: 'cjs',
sourcemap: true
sourcemap: true,
inlineDynamicImports: true
},
external: id => !/^yjs\//.test(id) && id[0] !== '.' && id[0] !== '/',
plugins: [
debugResolve,
// debugResolve,
nodeResolve({
mainFields: ['module', 'browser', 'main']
}),
postcss({
plugins: [],
extract: true
})
]
}, {
} /* {
input: './test/index.js',
output: {
name: 'test',
file: 'dist/test.js',
format: 'iife',
sourcemap: true
format: 'esm',
sourcemap: true,
inlineDynamicImports: true
},
plugins: [
debugResolve,
// debugResolve,
nodeResolve({
mainFields: ['module', 'browser', 'main']
}),
Expand All @@ -96,4 +55,4 @@ export default [{
extract: true
})
]
}]
} */]
6 changes: 3 additions & 3 deletions src/y-monaco.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as Y from 'yjs'
import * as monaco from 'monaco-editor'
import * as error from 'lib0/error.js'
import { createMutex } from 'lib0/mutex.js'
import { Awareness } from 'y-protocols/awareness.js' // eslint-disable-line
import * as error from 'lib0/error'
import { createMutex } from 'lib0/mutex'
import { Awareness } from 'y-protocols/awareness' // eslint-disable-line

class RelativeSelection {
/**
Expand Down
6 changes: 3 additions & 3 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

import * as monaco from './y-monaco.test.js'

import { runTests } from 'lib0/testing.js'
import { isBrowser, isNode } from 'lib0/environment.js'
import * as log from 'lib0/logging.js'
import { runTests } from 'lib0/testing'
import { isBrowser, isNode } from 'lib0/environment'
import * as log from 'lib0/logging'

if (isBrowser) {
log.createVConsole(document.body)
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions test/y-monaco.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import * as t from 'lib0/testing.js'
import * as prng from 'lib0/prng.js'
import * as math from 'lib0/math.js'
import * as t from 'lib0/testing'
import * as prng from 'lib0/prng'
import * as math from 'lib0/math'
import * as Y from 'yjs'
import { applyRandomTests } from 'yjs/tests/testHelper.js'
import { MonacoBinding } from '../src/y-monaco.js'
Expand Down

0 comments on commit ae2d46d

Please sign in to comment.