@@ -14,7 +14,7 @@ const esbuildBase = {
1414 minify : true ,
1515 platform : 'browser' ,
1616 charset : 'utf8' ,
17- target : [ 'firefox78' , 'chrome78' , 'safari11.1' ] ,
17+ target : [ 'es2020' , ' firefox78', 'chrome78' , 'safari11.1' ] ,
1818} ;
1919
2020/** @type {import('esbuild').Plugin } */
@@ -37,43 +37,61 @@ const kayrosFixPlugin = {
3737 } ,
3838} ;
3939
40- /** @type {Record<string, Partial<import('esbuild').BuildOptions>> } */
41- const builds = {
42- esm : {
43- format : 'esm' ,
44- outfile : './lib/monogatari.module.js' ,
45- sourcemap : 'linked' ,
46- } ,
47- cjs : {
48- format : 'cjs' ,
49- outfile : './lib/monogatari.node.js' ,
50- sourcemap : 'linked' ,
51- define : {
52- 'import.meta.url' : 'location' ,
40+ async function main ( ) {
41+ const { default : pluginBabel } = await import ( 'esbuild-plugin-babel' ) ;
42+
43+ /** @type {Record<string, Partial<import('esbuild').BuildOptions>> } */
44+ const builds = {
45+ esm : {
46+ format : 'esm' ,
47+ outfile : './lib/monogatari.module.js' ,
48+ sourcemap : 'linked' ,
5349 } ,
54- } ,
55- iife : {
56- entryPoints : [ './src/browser.js' ] ,
57- format : 'iife' ,
58- outfile : './dist/engine/core/monogatari.js' ,
59- globalName : 'Monogatari' ,
60- define : {
61- 'import.meta.url' : 'location' ,
50+ cjs : {
51+ format : 'cjs' ,
52+ outfile : './lib/monogatari.node.js' ,
53+ sourcemap : 'linked' ,
54+ define : {
55+ 'import.meta.url' : 'location' ,
56+ } ,
6257 } ,
63- } ,
64- debug : {
65- entryPoints : [ './debug/index.js' ] ,
66- format : 'iife' ,
67- outfile : './dist/engine/debug/debug.js' ,
68- } ,
69- css : {
70- entryPoints : [ './src/index.css' ] ,
71- outfile : './dist/engine/core/monogatari.css' ,
72- plugins : [ kayrosFixPlugin , sassPlugin ( ) ] ,
73- } ,
74- } ;
58+ iife : {
59+ entryPoints : [ './src/browser.js' ] ,
60+ format : 'iife' ,
61+ outfile : './dist/engine/core/monogatari.js' ,
62+ globalName : 'Monogatari' ,
63+ define : {
64+ 'import.meta.url' : 'location' ,
65+ } ,
66+ plugins : [
67+ pluginBabel ( {
68+ filter : / .j s $ / ,
69+ config : {
70+ presets : [
71+ [
72+ "@babel/preset-env" ,
73+ {
74+ useBuiltIns : "usage" ,
75+ corejs : 3
76+ }
77+ ]
78+ ]
79+ }
80+ } )
81+ ]
82+ } ,
83+ debug : {
84+ entryPoints : [ './debug/index.js' ] ,
85+ format : 'iife' ,
86+ outfile : './dist/engine/debug/debug.js' ,
87+ } ,
88+ css : {
89+ entryPoints : [ './src/index.css' ] ,
90+ outfile : './dist/engine/core/monogatari.css' ,
91+ plugins : [ kayrosFixPlugin , sassPlugin ( ) ] ,
92+ } ,
93+ } ;
7594
76- async function main ( ) {
7795 if ( DEV ) {
7896 const ctx = await context ( {
7997 ...esbuildBase ,
0 commit comments