mirror of
https://git.um-react.app/um/lib_um_crypto_rust.git
synced 2026-03-08 04:29:54 +00:00
build: experimental build with node package
This commit is contained in:
50
um_wasm_loader/rollup.config.mjs
Normal file
50
um_wasm_loader/rollup.config.mjs
Normal file
@@ -0,0 +1,50 @@
|
||||
import { defineConfig } from 'rollup';
|
||||
import { wasm } from '@rollup/plugin-wasm';
|
||||
import replace from '@rollup/plugin-replace';
|
||||
import { dts } from 'rollup-plugin-dts';
|
||||
|
||||
function makePlugins({ sync }) {
|
||||
const plugins = [];
|
||||
plugins.push(wasm({ sync: sync ? ['pkg/um_wasm_bg.wasm'] : [] }));
|
||||
plugins.push(
|
||||
replace({
|
||||
preventAssignment: true,
|
||||
values: {
|
||||
'process.env.UMC_INLINE_BUILD': JSON.stringify(String(sync ? 1 : 0)),
|
||||
},
|
||||
}),
|
||||
);
|
||||
return plugins;
|
||||
}
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
input: 'src/loader.mjs',
|
||||
output: {
|
||||
file: 'dist/loader.js',
|
||||
format: 'cjs',
|
||||
},
|
||||
plugins: [...makePlugins({ sync: false })],
|
||||
},
|
||||
{
|
||||
input: 'src/loader.mjs',
|
||||
output: {
|
||||
file: 'dist/loader.mjs',
|
||||
format: 'es',
|
||||
},
|
||||
plugins: [...makePlugins({ sync: false })],
|
||||
},
|
||||
{
|
||||
input: 'src/loader.mjs',
|
||||
output: {
|
||||
file: 'dist/loader-inline.js',
|
||||
format: 'cjs',
|
||||
},
|
||||
plugins: [...makePlugins({ sync: true })],
|
||||
},
|
||||
{
|
||||
input: './src/loader.d.ts',
|
||||
output: [{ file: 'dist/loader.d.ts', format: 'es' }],
|
||||
plugins: [dts()],
|
||||
},
|
||||
]);
|
||||
Reference in New Issue
Block a user