Merge pull request #957 from tidalcycles/web-iife

fix script importable packages (web + repl)
This commit is contained in:
Felix Roos 2024-02-23 14:37:45 +01:00 committed by GitHub
commit e9ab01ab06
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 33 additions and 14 deletions

View file

@ -1,10 +1,11 @@
{
"name": "@strudel/repl",
"version": "1.0.1",
"version": "1.0.2",
"description": "Strudel REPL as a Web Component",
"main": "index.mjs",
"module": "index.mjs",
"publishConfig": {
"main": "dist/index.mjs"
"main": "dist/index.js",
"module": "dist/index.mjs"
},
"scripts": {
"build": "vite build",

View file

@ -1,10 +1,11 @@
{
"name": "@strudel/web",
"version": "1.0.1",
"version": "1.0.3",
"description": "Easy to setup, opiniated bundle of Strudel for the browser.",
"main": "web.mjs",
"module": "web.mjs",
"publishConfig": {
"main": "dist/index.mjs"
"main": "dist/index.js",
"module": "dist/index.mjs"
},
"scripts": {
"build": "vite build",
@ -36,7 +37,8 @@
"@strudel/mini": "workspace:*",
"@strudel/tonal": "workspace:*",
"@strudel/transpiler": "workspace:*",
"@strudel/webaudio": "workspace:*"
"@strudel/webaudio": "workspace:*",
"@rollup/plugin-replace": "^5.0.5"
},
"devDependencies": {
"vite": "^5.0.10"

View file

@ -1,6 +1,7 @@
import { defineConfig } from 'vite';
import { dependencies } from './package.json';
import { resolve } from 'path';
import replace from '@rollup/plugin-replace';
// https://vitejs.dev/config/
export default defineConfig({
@ -8,11 +9,18 @@ export default defineConfig({
build: {
lib: {
entry: resolve(__dirname, 'web.mjs'),
formats: ['es'],
fileName: (ext) => ({ es: 'index.mjs' })[ext],
name: 'strudel',
formats: ['es', 'iife'],
fileName: (ext) => ({ es: 'index.mjs', iife: 'index.js' })[ext],
},
rollupOptions: {
external: [...Object.keys(dependencies)],
// external: [...Object.keys(dependencies)],
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
preventAssignment: true,
}),
],
},
target: 'esnext',
},