Skip to content

Commit 3c769d8

Browse files
committed
Not include FES in minified build
1 parent d700f36 commit 3c769d8

File tree

5 files changed

+44
-2
lines changed

5 files changed

+44
-2
lines changed

package-lock.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"omggif": "^1.0.10"
3535
},
3636
"devDependencies": {
37+
"@rollup/plugin-alias": "^5.1.1",
3738
"@rollup/plugin-commonjs": "^25.0.7",
3839
"@rollup/plugin-json": "^6.1.0",
3940
"@rollup/plugin-node-resolve": "^15.2.3",

rollup.config.mjs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import pkg from './package.json' assert { type: 'json' };
77
import dayjs from 'dayjs';
88
import { visualizer } from 'rollup-plugin-visualizer';
99
import replace from '@rollup/plugin-replace';
10+
import alias from '@rollup/plugin-alias';
1011

1112
const plugins = [
1213
commonjs(),
@@ -99,7 +100,19 @@ export default [
99100
plugins: [
100101
bundleSize('p5.esm.js')
101102
]
102-
},
103+
}
104+
],
105+
treeshake: {
106+
preset: 'smallest'
107+
},
108+
plugins: [
109+
...plugins
110+
]
111+
},
112+
//// Minified build ////
113+
{
114+
input: 'src/app.js',
115+
output: [
103116
{
104117
file: './lib/p5.min.js',
105118
format: 'iife',
@@ -125,9 +138,14 @@ export default [
125138
preset: 'smallest'
126139
},
127140
plugins: [
141+
alias({
142+
entries: [
143+
{ find: './core/friendly_errors', replacement: './core/noop' }
144+
]
145+
}),
128146
...plugins
129147
]
130-
},
148+
}
131149
// NOTE: comment to NOT build standalone math module
132150
// ...generateModuleBuild()
133151
];

src/core/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class p5 {
4242
remove: []
4343
};
4444

45+
// FES stub
46+
static _checkForUserDefinedFunctions = () => {};
47+
static _friendlyFileLoadError = () => {};
48+
4549
constructor(sketch, node) {
4650
//////////////////////////////////////////////
4751
// PRIVATE p5 PROPERTIES AND METHODS

src/core/noop.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default function(){}

0 commit comments

Comments
 (0)