Skip to content

Commit

Permalink
undo formatting changes in rollup config
Browse files Browse the repository at this point in the history
  • Loading branch information
leoortizz committed Nov 4, 2024
1 parent d0c22b1 commit f6c6805
Showing 1 changed file with 55 additions and 73 deletions.
128 changes: 55 additions & 73 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,129 +1,111 @@
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<any>}
*/
const customLibModules = new Set(["lib0", "y-protocols"])
const customLibModules = new Set(['lib0', 'y-protocols'])
const debugResolve = {
resolveId(importee) {
if (importee === "yjs") {
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",
input: './src/index.js',
output: {
name: "Y",
file: "dist/yjs.cjs",
format: "cjs",
sourcemap: true,
name: 'Y',
file: 'dist/yjs.cjs',
format: 'cjs',
sourcemap: true
},
external: (id) => /^lib0\//.test(id),
external: id => /^lib0\//.test(id)
},
{
input: "./src/index.js",
input: './src/index.js',
output: {
name: "Y",
file: "dist/yjs.mjs",
format: "esm",
sourcemap: true,
name: 'Y',
file: 'dist/yjs.mjs',
format: 'esm',
sourcemap: true
},
external: (id) => /^lib0\//.test(id),
external: id => /^lib0\//.test(id)
},
{
input: "./src/index.js",
input: './tests/testHelper.js',
output: {
name: "Y",
file: "dist/yjs.amd.js",
format: "amd",
sourcemap: true,
name: 'Y',
file: 'dist/testHelper.mjs',
format: 'esm',
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.
],
},
{
input: "./tests/testHelper.js",
output: {
name: "Y",
file: "dist/testHelper.mjs",
format: "esm",
sourcemap: true,
},
external: (id) => /^lib0\//.test(id) || id === "yjs",
external: id => /^lib0\//.test(id) || id === 'yjs',
plugins: [
{
resolveId(importee) {
if (importee === "../src/index.js") {
return "yjs"
if (importee === '../src/index.js') {
return 'yjs'
}
return null
},
},
],
}
}
]
},
{
input: "./tests/index.js",
input: './tests/index.js',
output: {
name: "test",
file: "dist/tests.js",
format: "iife",
sourcemap: true,
name: 'test',
file: 'dist/tests.js',
format: 'iife',
sourcemap: true
},
plugins: [
debugResolve,
nodeResolve({
mainFields: ["browser", "module", "main"],
mainFields: ['browser', 'module', 'main']
}),
commonjs(),
],
commonjs()
]
},
{
input: "./tests/index.js",
input: './tests/index.js',
output: {
name: "test",
file: "dist/tests.cjs",
format: "cjs",
sourcemap: true,
name: 'test',
file: 'dist/tests.cjs',
format: 'cjs',
sourcemap: true
},
plugins: [
debugResolve,
nodeResolve({
mainFields: ["node", "module", "main"],
exportConditions: ["node", "module", "import", "default"],
mainFields: ['node', 'module', 'main'],
exportConditions: ['node', 'module', 'import', 'default']
}),
commonjs(),
commonjs()
],
external: (id) => /^lib0\//.test(id),
},
external: id => /^lib0\//.test(id)
}
]

0 comments on commit f6c6805

Please sign in to comment.