Skip to content

Commit bae38d2

Browse files
committed
add core-js to standalone package
1 parent 3160f2a commit bae38d2

5 files changed

Lines changed: 1201 additions & 45 deletions

File tree

.browserslistrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
>0.3%, firefox >= 52, chrome >= 52, safari >= 11.1, last 2 versions, not dead

build.js

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -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: /.js$/,
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,

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@
3030
"test": "yarn run cypress"
3131
},
3232
"devDependencies": {
33+
"@babel/core": "^7.21.8",
34+
"@babel/preset-env": "^7.21.5",
35+
"@types/babel__core": "^7.20.0",
3336
"autoprefixer": "^10.4.14",
37+
"core-js": "^3.30.2",
3438
"cypress": "^9.2.1",
3539
"dotenv": "^11.0.0",
3640
"electron-notarize": "^1.1.1",
41+
"esbuild-plugin-babel": "^0.2.3",
3742
"eslint": "^8.6.0",
3843
"htmlhint": "^1.1.0",
3944
"jsdoc": "^3.6.7",

src/browser.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
/**
2-
* This is a small hack required to replicate the "global" availability of
3-
* Monogatari as a library in the window object. Parcel v1 previously had an
4-
* option for this that has been removed in v2 so this is just a way around it.
5-
* Once an alternative is provided by parcel, this should be removed.
6-
*/
7-
81
import * as Monogatari from './index.js';
92

103
if (typeof window !== 'undefined') {

0 commit comments

Comments
 (0)