diff options
| author | AAGaming <aagaming@riseup.net> | 2024-08-07 16:14:18 -0400 |
|---|---|---|
| committer | AAGaming <aagaming@riseup.net> | 2024-08-07 16:14:18 -0400 |
| commit | 65b6883dcc42944607eb0efa1f28e41f57335313 (patch) | |
| tree | 38db3185d6720552daa978149279928d271df19a /frontend/rollup.config.js | |
| parent | 166c7ea8a7ea74d9a61d84ebe16556cec9e7cc83 (diff) | |
| download | decky-loader-65b6883dcc42944607eb0efa1f28e41f57335313.tar.gz decky-loader-65b6883dcc42944607eb0efa1f28e41f57335313.zip | |
handle crashloops and disable decky for the user
Diffstat (limited to 'frontend/rollup.config.js')
| -rw-r--r-- | frontend/rollup.config.js | 100 |
1 files changed, 57 insertions, 43 deletions
diff --git a/frontend/rollup.config.js b/frontend/rollup.config.js index 2c731e54..57804c4f 100644 --- a/frontend/rollup.config.js +++ b/frontend/rollup.config.js @@ -11,48 +11,62 @@ import { visualizer } from 'rollup-plugin-visualizer'; const hiddenWarnings = ['THIS_IS_UNDEFINED', 'EVAL']; -export default defineConfig({ - input: 'src/index.ts', - plugins: [ - del({ targets: '../backend/decky_loader/static/*', force: true }), - commonjs(), - nodeResolve({ - browser: true, - }), - externalGlobals({ - react: 'SP_REACT', - 'react-dom': 'SP_REACTDOM', - // hack to shut up react-markdown - process: '{cwd: () => {}}', - path: '{dirname: () => {}, join: () => {}, basename: () => {}, extname: () => {}}', - url: '{fileURLToPath: (f) => f}', - }), - typescript(), - json(), - replace({ - preventAssignment: false, - 'process.env.NODE_ENV': JSON.stringify('production'), - }), - image(), - visualizer(), - ], - preserveEntrySignatures: false, - treeshake: { - // Assume all external modules have imports with side effects (the default) while allowing decky libraries to treeshake - pureExternalImports: true, - preset: 'smallest' - }, - output: { - dir: '../backend/decky_loader/static', - format: 'esm', - chunkFileNames: (chunkInfo) => { - return 'chunk-[hash].js'; +export default defineConfig([ + // Main bundle + { + input: 'src/index.ts', + plugins: [ + del({ targets: ['../backend/decky_loader/static/*', '!../backend/decky_loader/static/fallback.js'], force: true }), + commonjs(), + nodeResolve({ + browser: true, + }), + externalGlobals({ + react: 'SP_REACT', + 'react-dom': 'SP_REACTDOM', + // hack to shut up react-markdown + process: '{cwd: () => {}}', + path: '{dirname: () => {}, join: () => {}, basename: () => {}, extname: () => {}}', + url: '{fileURLToPath: (f) => f}', + }), + typescript(), + json(), + replace({ + preventAssignment: false, + 'process.env.NODE_ENV': JSON.stringify('production'), + }), + image(), + visualizer(), + ], + preserveEntrySignatures: false, + treeshake: { + // Assume all external modules have imports with side effects (the default) while allowing decky libraries to treeshake + pureExternalImports: true, + preset: 'smallest' + }, + output: { + dir: '../backend/decky_loader/static', + format: 'esm', + chunkFileNames: (chunkInfo) => { + return 'chunk-[hash].js'; + }, + sourcemap: true, + sourcemapPathTransform: (relativeSourcePath) => relativeSourcePath.replace(/^\.\.\//, `decky://decky/loader/`), + }, + onwarn: function (message, handleWarning) { + if (hiddenWarnings.some((warning) => message.code === warning)) return; + handleWarning(message); }, - sourcemap: true, - sourcemapPathTransform: (relativeSourcePath) => relativeSourcePath.replace(/^\.\.\//, `decky://decky/loader/`), - }, - onwarn: function (message, handleWarning) { - if (hiddenWarnings.some((warning) => message.code === warning)) return; - handleWarning(message); }, -}); + // Fallback + { + input: 'src/fallback.ts', + plugins: [ + typescript() + ], + output: { + file: '../backend/decky_loader/static/fallback.js', + format: 'esm', + } + } +]); |
