clean up build script - no more warnings

This commit is contained in:
Kevin Jahns 2019-03-13 01:16:31 +01:00
parent 57975d409e
commit 040808300c
7 changed files with 12 additions and 86 deletions

View File

@ -1,4 +1,4 @@
import * as Y from '../src/index.js' import * as Y from 'yjs'
import { WebsocketProvider } from 'y-websocket' import { WebsocketProvider } from 'y-websocket'
import { prosemirrorPlugin, cursorPlugin } from 'y-prosemirror' import { prosemirrorPlugin, cursorPlugin } from 'y-prosemirror'

View File

@ -8,12 +8,12 @@
"scripts": { "scripts": {
"test": "npm run lint && npm run dist && node ./dist/tests.js --repitition-time 50", "test": "npm run lint && npm run dist && node ./dist/tests.js --repitition-time 50",
"test-exhaustive": "npm run lint && npm run dist && node ./dist/tests.js --repitition-time 10000", "test-exhaustive": "npm run lint && npm run dist && node ./dist/tests.js --repitition-time 10000",
"dist": "rm -rf dist examples/build && PRODUCTION=1 rollup -c", "dist": "rm -rf dist examples/build && rollup -c",
"watch": "rollup -wc", "watch": "rollup -wc",
"lint": "standard", "lint": "standard",
"docs": "rm -rf docs; jsdoc --configure ./.jsdoc.json --verbose --readme ./README.v13.md --package ./package.json || true", "docs": "rm -rf docs; jsdoc --configure ./.jsdoc.json --verbose --readme ./README.v13.md --package ./package.json || true",
"serve-docs": "npm run docs && serve ./docs/", "serve-docs": "npm run docs && serve ./docs/",
"postversion": "npm run dist", "postversion": "PRODUCTION=1 npm run dist",
"debug": "concurrently 'live-server --port=3443 --entry-file=test.html' 'npm run watch'", "debug": "concurrently 'live-server --port=3443 --entry-file=test.html' 'npm run watch'",
"trace-deopt": "clear && rollup -c && node --trace-deopt dist/test.js", "trace-deopt": "clear && rollup -c && node --trace-deopt dist/test.js",
"trace-opt": "clear && rollup -c && node --trace-opt dist/test.js" "trace-opt": "clear && rollup -c && node --trace-opt dist/test.js"

View File

@ -33,7 +33,6 @@ const debugResolve = {
} }
} }
// set this to [] to disable obfuscation
const minificationPlugins = process.env.PRODUCTION ? [terser({ const minificationPlugins = process.env.PRODUCTION ? [terser({
module: true, module: true,
compress: { compress: {
@ -46,13 +45,12 @@ const minificationPlugins = process.env.PRODUCTION ? [terser({
}, },
mangle: { mangle: {
toplevel: true toplevel: true
// properties: true
} }
})] : [] })] : []
export default [{ export default [{
input: './src/index.js', input: './src/index.js',
output: { output: [{
name: 'Y', name: 'Y',
file: 'dist/yjs.js', file: 'dist/yjs.js',
format: 'cjs', format: 'cjs',
@ -63,17 +61,13 @@ export default [{
} }
return path return path
} }
}, }, {
plugins: minificationPlugins
}, {
input: './src/index.js',
output: {
name: 'Y', name: 'Y',
file: 'dist/yjs.mjs', file: 'dist/yjs.mjs',
format: 'esm', format: 'esm',
sourcemap: true sourcemap: true
}, }],
plugins: minificationPlugins external: id => /^lib0\//.test(id)
}, { }, {
input: './tests/index.js', input: './tests/index.js',
output: { output: {
@ -91,24 +85,7 @@ export default [{
}), }),
commonjs() commonjs()
] ]
}, }, {
/* {
input: 'tests/index.js',
output: {
file: 'dist/y.test.js',
format: 'iife',
name: 'ytests',
sourcemap: true
},
plugins: [
nodeResolve({
main: true,
module: true
}),
commonjs()
]
}, */{
input: ['./examples/codemirror.js', './examples/textarea.js', './examples/quill.js', './examples/dom.js', './examples/prosemirror.js'], // fs.readdirSync('./examples').filter(file => /(?<!\.(test|config))\.js$/.test(file)).map(file => './examples/' + file), input: ['./examples/codemirror.js', './examples/textarea.js', './examples/quill.js', './examples/dom.js', './examples/prosemirror.js'], // fs.readdirSync('./examples').filter(file => /(?<!\.(test|config))\.js$/.test(file)).map(file => './examples/' + file),
output: { output: {
dir: 'examples/build', dir: 'examples/build',

View File

@ -24,7 +24,7 @@ export { getRelativePosition, fromRelativePosition, equal as equalRelativePositi
export { ID, createID, RootFakeUserID, RootID } from './utils/ID.js' export { ID, createID, RootFakeUserID, RootID } from './utils/ID.js'
export { DeleteStore, DSNode } from './utils/DeleteStore.js' export { DeleteStore, DSNode } from './utils/DeleteStore.js'
export { deleteItemRange } from './utils/structManipulation.js' export { deleteItemRange } from './utils/structManipulation.js'
export { integrateRemoteStruct, integrateRemoteStructs } from './utils/integrateRemoteStructs.js' export { integrateRemoteStructs } from './utils/integrateRemoteStructs.js'
export { isParentOf } from './utils/isParentOf.js' export { isParentOf } from './utils/isParentOf.js'
export { stringifyItemID } from './utils/structStringify.js' export { stringifyItemID } from './utils/structStringify.js'

View File

@ -112,51 +112,3 @@ export const integrateRemoteStructs = (decoder, y) => {
} }
} }
} }
// TODO: use this above / refactor
/**
* @param {decoding.Decoder} decoder
* @param {Y} y
*/
export const integrateRemoteStruct = (decoder, y) => {
let reference = decoding.readVarUint(decoder)
let Constr = getStruct(reference)
let struct = new Constr()
let decoderPos = decoder.pos
let missing = struct._fromBinary(y, decoder)
if (missing.length === 0) {
while (struct != null) {
_integrateRemoteStructHelper(y, struct)
struct = null
if (y._readyToIntegrate.length > 0) {
const missingDef = y._readyToIntegrate.shift()
const decoder = missingDef.decoder
let oldPos = decoder.pos
let missing = missingDef.struct._fromBinary(y, decoder)
decoder.pos = oldPos
if (missing.length === 0) {
struct = missingDef.struct
} else {
throw new Error('Missing should be empty')
}
}
}
} else {
let _decoder = decoding.createDecoder(decoder.arr.buffer)
_decoder.pos = decoderPos
let missingEntry = new MissingEntry(_decoder, missing, struct)
let missingStructs = y._missingStructs
for (let i = missing.length - 1; i >= 0; i--) {
let m = missing[i]
if (!missingStructs.has(m.user)) {
missingStructs.set(m.user, new Map())
}
let msu = missingStructs.get(m.user)
if (!msu.has(m.clock)) {
msu.set(m.clock, [])
}
let mArray = msu = msu.get(m.clock)
mArray.push(missingEntry)
}
}
}

View File

@ -23,13 +23,9 @@ export const registerStruct = (reference, structConstructor) => {
/** /**
* @private * @private
*/ */
export const getStruct = (reference) => { export const getStruct = structs.get.bind(structs) // reference => structs.get(reference)
return structs.get(reference)
}
/** /**
* @private * @private
*/ */
export const getStructReference = (typeConstructor) => { export const getStructReference = references.get.bind(references) // typeConstructor => references.get(typeConstructor)
return references.get(typeConstructor)
}

1
todo.md Normal file
View File

@ -0,0 +1 @@
* npm run test -- --filter "\[41/" --seed 1273720726