13
13
* limitations under the License.
14
14
*/
15
15
16
- const { nodeResolve : resolve } = require ( '@rollup/plugin-node-resolve' ) ;
17
- const replace = require ( '@rollup/plugin-replace' ) ;
18
- const cleanup = require ( 'rollup-plugin-cleanup' ) ;
19
- const { terser } = require ( 'rollup-plugin-terser' ) ;
20
- const commonjs = require ( '@rollup/plugin-commonjs' ) ;
21
- const polyfill = require ( 'rollup-plugin-polyfill' ) ;
16
+ import commonjs from '@rollup/plugin-commonjs' ;
17
+ import { nodeResolve as resolve } from '@rollup/plugin-node-resolve' ;
18
+ import replace from '@rollup/plugin-replace' ;
19
+ import terser from '@rollup/plugin-terser' ;
20
+ import cleanup from 'rollup-plugin-cleanup' ;
22
21
import dts from 'rollup-plugin-dts' ;
22
+ import polyfill from 'rollup-plugin-polyfill' ;
23
23
24
- const { NODE_ENV } = process . env ;
24
+ const { NODE_ENV } = process . env ;
25
25
26
26
const onwarn = ( warning , warn ) => {
27
27
// Suppress non-actionable warning caused by TypeScript boilerplate:
@@ -30,40 +30,39 @@ const onwarn = (warning, warn) => {
30
30
}
31
31
} ;
32
32
33
- let commonPlugins = [
34
- resolve ( { dedupe : 'three' } ) ,
35
- replace ( { 'Reflect.decorate' : 'undefined' } )
36
- ] ;
33
+ let commonPlugins =
34
+ [ resolve ( { dedupe : 'three' } ) , replace ( { 'Reflect.decorate' : 'undefined' } ) ] ;
37
35
38
36
const watchFiles = [ 'lib/**' ] ;
39
37
40
- const createModelViewerOutput = ( file , format , plugins = commonPlugins , external = [ ] ) => {
41
- const globals = external . reduce ( ( acc , mod ) => {
42
- acc [ mod ] = mod ; // Assuming global variable names are the same as module names
43
- return acc ;
44
- } , { } ) ;
38
+ const createModelViewerOutput =
39
+ ( file , format , plugins = commonPlugins , external = [ ] ) => {
40
+ const globals = external . reduce ( ( acc , mod ) => {
41
+ acc [ mod ] =
42
+ mod ; // Assuming global variable names are the same as module names
43
+ return acc ;
44
+ } , { } ) ;
45
45
46
- return {
47
- input : './lib/model-viewer.js' ,
48
- output : {
49
- file,
50
- format,
51
- sourcemap : true ,
52
- name : 'ModelViewerElement' ,
53
- globals
54
- } ,
55
- external,
56
- watch : {
57
- include : watchFiles
58
- } ,
59
- plugins,
60
- onwarn
61
- } ;
62
- } ;
46
+ return {
47
+ input : './lib/model-viewer.js' ,
48
+ output : {
49
+ file,
50
+ format,
51
+ sourcemap : true ,
52
+ name : 'ModelViewerElement' ,
53
+ globals
54
+ } ,
55
+ external,
56
+ watch : { include : watchFiles } ,
57
+ plugins,
58
+ onwarn
59
+ } ;
60
+ } ;
63
61
64
62
const outputOptions = [
65
63
createModelViewerOutput ( './dist/model-viewer.js' , 'esm' ) ,
66
- createModelViewerOutput ( './dist/model-viewer-module.js' , 'esm' , commonPlugins , [ 'three' ] )
64
+ createModelViewerOutput (
65
+ './dist/model-viewer-module.js' , 'esm' , commonPlugins , [ 'three' ] )
67
66
] ;
68
67
69
68
if ( NODE_ENV !== 'development' ) {
@@ -82,20 +81,28 @@ if (NODE_ENV !== 'development') {
82
81
// IE11 does not support modules, so they are removed here, as well as in a
83
82
// dedicated unit test build which is needed for the same reason.
84
83
outputOptions . push (
85
- createModelViewerOutput ( './dist/model-viewer-umd.js' , 'umd' , pluginsIE11 ) ,
84
+ createModelViewerOutput ( './dist/model-viewer-umd.js' , 'umd' , pluginsIE11 ) ,
86
85
/** Bundled w/o three */
87
- createModelViewerOutput ( './dist/model-viewer-module-umd.js' , 'umd' , pluginsIE11 , [ 'three' ] )
88
- ) ;
86
+ createModelViewerOutput (
87
+ './dist/model-viewer-module-umd.js' , 'umd' , pluginsIE11 , [ 'three' ] ) ) ;
89
88
90
89
// Minified Versions
91
90
const minifiedPlugins = [ ...commonPlugins , terser ( ) ] ;
92
91
93
92
outputOptions . push (
94
- createModelViewerOutput ( './dist/model-viewer.min.js' , 'esm' , minifiedPlugins ) ,
95
- createModelViewerOutput ( './dist/model-viewer-umd.min.js' , 'umd' , minifiedPlugins ) ,
96
- createModelViewerOutput ( './dist/model-viewer-module.min.js' , 'esm' , minifiedPlugins , [ 'three' ] ) ,
97
- createModelViewerOutput ( './dist/model-viewer-module-umd.min.js' , 'umd' , minifiedPlugins , [ 'three' ] )
98
- ) ;
93
+ createModelViewerOutput (
94
+ './dist/model-viewer.min.js' , 'esm' , minifiedPlugins ) ,
95
+ createModelViewerOutput (
96
+ './dist/model-viewer-umd.min.js' , 'umd' , minifiedPlugins ) ,
97
+ createModelViewerOutput (
98
+ './dist/model-viewer-module.min.js' ,
99
+ 'esm' ,
100
+ minifiedPlugins ,
101
+ [ 'three' ] ) ,
102
+ createModelViewerOutput (
103
+ './dist/model-viewer-module-umd.min.js' , 'umd' , minifiedPlugins , [
104
+ 'three'
105
+ ] ) ) ;
99
106
100
107
outputOptions . push ( {
101
108
input : './lib/model-viewer.d.ts' ,
0 commit comments