1
- import nodeResolve from " @rollup/plugin-node-resolve"
2
- import commonjs from " @rollup/plugin-commonjs"
1
+ import nodeResolve from ' @rollup/plugin-node-resolve'
2
+ import commonjs from ' @rollup/plugin-commonjs'
3
3
4
4
const localImports = process . env . LOCALIMPORTS
5
5
6
6
const customModules = new Set ( [
7
- " y-websocket" ,
8
- " y-codemirror" ,
9
- " y-ace" ,
10
- " y-textarea" ,
11
- " y-quill" ,
12
- " y-dom" ,
13
- " y-prosemirror" ,
7
+ ' y-websocket' ,
8
+ ' y-codemirror' ,
9
+ ' y-ace' ,
10
+ ' y-textarea' ,
11
+ ' y-quill' ,
12
+ ' y-dom' ,
13
+ ' y-prosemirror'
14
14
] )
15
15
/**
16
16
* @type {Set<any> }
17
17
*/
18
- const customLibModules = new Set ( [ "lib0" , "y-protocols" ] )
18
+ const customLibModules = new Set ( [
19
+ 'lib0' ,
20
+ 'y-protocols'
21
+ ] )
19
22
const debugResolve = {
20
- resolveId ( importee ) {
21
- if ( importee === " yjs" ) {
23
+ resolveId ( importee ) {
24
+ if ( importee === ' yjs' ) {
22
25
return `${ process . cwd ( ) } /src/index.js`
23
26
}
24
27
if ( localImports ) {
25
- if ( customModules . has ( importee . split ( "/" ) [ 0 ] ) ) {
28
+ if ( customModules . has ( importee . split ( '/' ) [ 0 ] ) ) {
26
29
return `${ process . cwd ( ) } /../${ importee } /src/${ importee } .js`
27
30
}
28
- if ( customLibModules . has ( importee . split ( "/" ) [ 0 ] ) ) {
31
+ if ( customLibModules . has ( importee . split ( '/' ) [ 0 ] ) ) {
29
32
return `${ process . cwd ( ) } /../${ importee } `
30
33
}
31
34
}
32
35
return null
33
- } ,
36
+ }
34
37
}
35
38
36
- export default [
37
- {
38
- input : "./src/index.js" ,
39
- output : {
40
- name : "Y" ,
41
- file : "dist/yjs.cjs" ,
42
- format : "cjs" ,
43
- sourcemap : true ,
44
- } ,
45
- external : ( id ) => / ^ l i b 0 \/ / . test ( id ) ,
39
+ export default [ {
40
+ input : './src/index.js' ,
41
+ output : {
42
+ name : 'Y' ,
43
+ file : 'dist/yjs.cjs' ,
44
+ format : 'cjs' ,
45
+ sourcemap : true
46
46
} ,
47
- {
48
- input : "./src/index.js" ,
49
- output : {
50
- name : "Y" ,
51
- file : "dist/yjs.mjs" ,
52
- format : "esm" ,
53
- sourcemap : true ,
54
- } ,
55
- external : ( id ) => / ^ l i b 0 \/ / . test ( id ) ,
47
+ external : id => / ^ l i b 0 \/ / . test ( id )
48
+ } , {
49
+ input : './src/index.js' ,
50
+ output : {
51
+ name : 'Y' ,
52
+ file : 'dist/yjs.mjs' ,
53
+ format : 'esm' ,
54
+ sourcemap : true
56
55
} ,
57
- {
58
- input : "./src/index.js" ,
59
- output : {
60
- name : "Y" ,
61
- file : "dist/yjs.amd.js" ,
62
- format : "amd" ,
63
- sourcemap : true ,
64
- } ,
65
- plugins : [
66
- nodeResolve ( {
67
- browser : true , // Use browser-compatible versions of modules
68
- extensions : [ ".js" , ".ts" ] ,
69
- preferBuiltins : false , // Do not prefer Node.js built-ins
70
- } ) ,
71
- commonjs ( ) ,
72
- // terser, etc.
73
- ] ,
56
+ external : id => / ^ l i b 0 \/ / . test ( id )
57
+ } , {
58
+ input : './tests/testHelper.js' ,
59
+ output : {
60
+ name : 'Y' ,
61
+ file : 'dist/testHelper.mjs' ,
62
+ format : 'esm' ,
63
+ sourcemap : true
74
64
} ,
75
- {
76
- input : "./tests/testHelper.js" ,
77
- output : {
78
- name : "Y" ,
79
- file : "dist/testHelper.mjs" ,
80
- format : "esm" ,
81
- sourcemap : true ,
82
- } ,
83
- external : ( id ) => / ^ l i b 0 \/ / . test ( id ) || id === "yjs" ,
84
- plugins : [
85
- {
86
- resolveId ( importee ) {
87
- if ( importee === "../src/index.js" ) {
88
- return "yjs"
89
- }
90
- return null
91
- } ,
92
- } ,
93
- ] ,
65
+ external : id => / ^ l i b 0 \/ / . test ( id ) || id === 'yjs' ,
66
+ plugins : [ {
67
+ resolveId ( importee ) {
68
+ if ( importee === '../src/index.js' ) {
69
+ return 'yjs'
70
+ }
71
+ return null
72
+ }
73
+ } ]
74
+ } , {
75
+ input : './tests/index.js' ,
76
+ output : {
77
+ name : 'test' ,
78
+ file : 'dist/tests.js' ,
79
+ format : 'iife' ,
80
+ sourcemap : true
94
81
} ,
95
- {
96
- input : "./tests/index.js" ,
97
- output : {
98
- name : "test" ,
99
- file : "dist/tests.js" ,
100
- format : "iife" ,
101
- sourcemap : true ,
102
- } ,
103
- plugins : [
104
- debugResolve ,
105
- nodeResolve ( {
106
- mainFields : [ "browser" , "module" , "main" ] ,
107
- } ) ,
108
- commonjs ( ) ,
109
- ] ,
82
+ plugins : [
83
+ debugResolve ,
84
+ nodeResolve ( {
85
+ mainFields : [ 'browser' , 'module' , 'main' ]
86
+ } ) ,
87
+ commonjs ( )
88
+ ]
89
+ } , {
90
+ input : './tests/index.js' ,
91
+ output : {
92
+ name : 'test' ,
93
+ file : 'dist/tests.cjs' ,
94
+ format : 'cjs' ,
95
+ sourcemap : true
110
96
} ,
111
- {
112
- input : "./tests/index.js" ,
113
- output : {
114
- name : "test" ,
115
- file : "dist/tests.cjs" ,
116
- format : "cjs" ,
117
- sourcemap : true ,
118
- } ,
119
- plugins : [
120
- debugResolve ,
121
- nodeResolve ( {
122
- mainFields : [ "node" , "module" , "main" ] ,
123
- exportConditions : [ "node" , "module" , "import" , "default" ] ,
124
- } ) ,
125
- commonjs ( ) ,
126
- ] ,
127
- external : ( id ) => / ^ l i b 0 \/ / . test ( id ) ,
97
+ plugins : [
98
+ debugResolve ,
99
+ nodeResolve ( {
100
+ mainFields : [ 'node' , 'module' , 'main' ] ,
101
+ exportConditions : [ 'node' , 'module' , 'import' , 'default' ]
102
+ } ) ,
103
+ commonjs ( )
104
+ ] ,
105
+ external : id => / ^ l i b 0 \/ / . test ( id )
106
+ } , {
107
+ input : './src/index.js' ,
108
+ output : {
109
+ name : 'Y' ,
110
+ file : 'dist/yjs.amd.js' ,
111
+ format : 'amd' ,
112
+ sourcemap : true
128
113
} ,
129
- ]
114
+ plugins : [
115
+ nodeResolve ( {
116
+ browser : true , // Use browser-compatible versions of modules
117
+ extensions : [ '.js' , '.ts' ] ,
118
+ preferBuiltins : false // Do not prefer Node.js built-ins
119
+ } ) ,
120
+ commonjs ( )
121
+ ]
122
+ } ]
0 commit comments