1313 * limitations under the License.
1414 */
1515
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' ;
2221import dts from 'rollup-plugin-dts' ;
22+ import polyfill from 'rollup-plugin-polyfill' ;
2323
24- const { NODE_ENV } = process . env ;
24+ const { NODE_ENV } = process . env ;
2525
2626const onwarn = ( warning , warn ) => {
2727 // Suppress non-actionable warning caused by TypeScript boilerplate:
@@ -30,40 +30,39 @@ const onwarn = (warning, warn) => {
3030 }
3131} ;
3232
33- let commonPlugins = [
34- resolve ( { dedupe : 'three' } ) ,
35- replace ( { 'Reflect.decorate' : 'undefined' } )
36- ] ;
33+ let commonPlugins =
34+ [ resolve ( { dedupe : 'three' } ) , replace ( { 'Reflect.decorate' : 'undefined' } ) ] ;
3735
3836const watchFiles = [ 'lib/**' ] ;
3937
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+ } , { } ) ;
4545
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+ } ;
6361
6462const outputOptions = [
6563 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' ] )
6766] ;
6867
6968if ( NODE_ENV !== 'development' ) {
@@ -82,20 +81,28 @@ if (NODE_ENV !== 'development') {
8281 // IE11 does not support modules, so they are removed here, as well as in a
8382 // dedicated unit test build which is needed for the same reason.
8483 outputOptions . push (
85- createModelViewerOutput ( './dist/model-viewer-umd.js' , 'umd' , pluginsIE11 ) ,
84+ createModelViewerOutput ( './dist/model-viewer-umd.js' , 'umd' , pluginsIE11 ) ,
8685 /** 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' ] ) ) ;
8988
9089 // Minified Versions
9190 const minifiedPlugins = [ ...commonPlugins , terser ( ) ] ;
9291
9392 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+ ] ) ) ;
99106
100107 outputOptions . push ( {
101108 input : './lib/model-viewer.d.ts' ,
0 commit comments