deno.land / x / wasm@wasmer-sdk-v0.6.0 / rollup.config.mjs

rollup.config.mjs
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import terser from "@rollup/plugin-terser";import pkg from "./package.json" assert { type: "json" };import dts from "rollup-plugin-dts";import typescript from "@rollup/plugin-typescript";import replace from "@rollup/plugin-replace";import copy from 'rollup-plugin-copy';import { wasm } from '@rollup/plugin-wasm';
const LIBRARY_NAME = "WasmerSDK"; // Change with your library's nameconst EXTERNAL = []; // Indicate which modules should be treated as externalconst GLOBALS = {}; // https://rollupjs.org/guide/en/#outputglobals
const banner = `/*! * ${pkg.name} * ${pkg.description} * * @version v${pkg.version} * @author ${pkg.author} * @homepage ${pkg.homepage} * @repository ${pkg.repository.url} * @license ${pkg.license} */`;
const makeConfig = (env = "development", input, name, plugins = []) => { const config = { input, external: EXTERNAL, output: [ { banner, name: name, file: `dist/${name}.umd.js`, format: "umd", exports: "auto", globals: GLOBALS, }, { banner, file: `dist/${name}.cjs`, format: "cjs", exports: "auto", globals: GLOBALS, }, { banner, file: `dist/${name}.js`, format: "es", exports: "named", globals: GLOBALS, }, ], plugins: [ typescript(), ...plugins, copy({ targets: [ { src: ['pkg/wasmer_js_bg.wasm', 'pkg/wasmer_js_bg.wasm.d.ts'], dest: 'dist' }, ] }) ], };
if (env === "production") { config.plugins.push( terser({ output: { comments: /^!/, }, }), ); } config.plugins.push( replace({ values: { "globalThis.wasmUrl": `"https://unpkg.com/${pkg.name}@${pkg.version}/dist/wasmer_js_bg.wasm"`, "globalThis.workerUrl": `"https://unpkg.com/${pkg.name}@${pkg.version}/dist/WasmerSDK.js"`, }, preventAssignment: true, }), );
return config;};
export default commandLineArgs => { let env = commandLineArgs.environment === "BUILD:production" ? "production" : null; const configs = [ makeConfig(env, "WasmerSDK.ts", LIBRARY_NAME), makeConfig(env, "WasmerSDKBundled.ts", `${LIBRARY_NAME}Bundled`, [wasm({ maxFileSize: 100 * 1024 * 1024, })]), { input: "./pkg/wasmer_js.d.ts", output: [{ file: "dist/pkg/wasmer_js.d.ts", format: "es" }], plugins: [dts()], }, ];
return configs;};
wasm

Version Info

Tagged at
4 months ago