Files
yjs/rollup.config.js

88 lines
1.7 KiB
JavaScript
Raw Normal View History

2020-01-13 07:41:31 +01:00
import nodeResolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
const localImports = process.env.LOCALIMPORTS
2019-03-01 23:26:40 +01:00
const customModules = new Set([
'y-websocket',
'y-codemirror',
'y-ace',
'y-textarea',
'y-quill',
'y-dom',
'y-prosemirror'
])
2019-03-12 01:42:51 +01:00
/**
* @type {Set<any>}
*/
2019-03-01 23:26:40 +01:00
const customLibModules = new Set([
2019-03-13 00:04:19 +01:00
'lib0',
'y-protocols'
2019-03-01 23:26:40 +01:00
])
const debugResolve = {
resolveId (importee) {
if (importee === 'yjs') {
return `${process.cwd()}/src/index.js`
}
if (localImports) {
if (customModules.has(importee.split('/')[0])) {
2020-01-14 02:36:29 +01:00
return `${process.cwd()}/../${importee}/src/${importee}.js`
}
if (customLibModules.has(importee.split('/')[0])) {
return `${process.cwd()}/../${importee}`
}
2019-03-01 23:26:40 +01:00
}
return null
}
}
2018-11-25 03:17:00 +01:00
export default [{
2019-03-01 23:26:40 +01:00
input: './src/index.js',
2020-01-13 07:41:31 +01:00
output: {
2018-11-25 03:17:00 +01:00
name: 'Y',
2020-01-13 07:41:31 +01:00
file: 'dist/yjs.cjs',
2018-11-25 22:39:30 +01:00
format: 'cjs',
2019-03-01 23:26:40 +01:00
sourcemap: true,
paths: path => {
2019-04-09 04:01:37 +02:00
if (/^lib0\//.test(path)) {
2020-01-13 07:41:31 +01:00
return `lib0/dist/${path.slice(5, -3)}.cjs`
2019-03-01 23:26:40 +01:00
}
return path
}
2020-01-13 07:41:31 +01:00
},
external: id => /^lib0\//.test(id)
}, {
2019-03-01 23:26:40 +01:00
input: './tests/index.js',
output: {
2019-03-01 23:26:40 +01:00
name: 'test',
file: 'dist/tests.js',
format: 'iife',
sourcemap: true
},
plugins: [
2019-03-01 23:26:40 +01:00
debugResolve,
nodeResolve({
sourcemap: true,
mainFields: ['module', 'browser', 'main']
2020-01-13 07:41:31 +01:00
}),
commonjs()
2019-03-01 23:26:40 +01:00
]
2020-01-13 07:41:31 +01:00
}, {
input: './tests/index.js',
output: {
name: 'test',
file: 'dist/tests.cjs',
format: 'cjs',
sourcemap: true
},
plugins: [
debugResolve,
nodeResolve({
sourcemap: true,
mainFields: ['module', 'main']
}),
commonjs()
],
external: ['isomorphic.js']
2019-04-23 20:51:32 +02:00
}]