fix: repl package import on server

This commit is contained in:
Felix Roos 2023-12-15 23:27:38 +01:00
parent 9c13f6bb53
commit 89c06046b5
3 changed files with 72 additions and 74 deletions

View file

@ -1,8 +1 @@
// nanostores use process.env which kills the browser build
window.process = {
env: {
NODE_ENV: 'development',
},
};
export * from './repl-component.mjs'; export * from './repl-component.mjs';

View file

@ -1,5 +1,4 @@
import { controls, evalScope } from '@strudel.cycles/core'; import { controls, evalScope } from '@strudel.cycles/core';
import { registerSoundfonts } from '@strudel.cycles/soundfonts';
import { registerSynthSounds, registerZZFXSounds, samples } from '@strudel.cycles/webaudio'; import { registerSynthSounds, registerZZFXSounds, samples } from '@strudel.cycles/webaudio';
import * as core from '@strudel.cycles/core'; import * as core from '@strudel.cycles/core';
@ -26,7 +25,11 @@ export async function prebake() {
modulesLoading, modulesLoading,
registerSynthSounds(), registerSynthSounds(),
registerZZFXSounds(), registerZZFXSounds(),
registerSoundfonts(), //registerSoundfonts(),
// need dynamic import here, because importing @strudel.cycles/soundfonts fails on server:
// => getting "window is not defined", as soon as "@strudel.cycles/soundfonts" is imported statically
// seems to be a problem with soundfont2
import('@strudel.cycles/soundfonts').then(({ registerSoundfonts }) => registerSoundfonts()),
samples(`${ds}/tidal-drum-machines.json`), samples(`${ds}/tidal-drum-machines.json`),
samples(`${ds}/piano.json`), samples(`${ds}/piano.json`),
samples(`${ds}/Dirt-Samples.json`), samples(`${ds}/Dirt-Samples.json`),

View file

@ -40,6 +40,7 @@ const parseAttribute = (name, value) => {
return value; return value;
}; };
// console.log('attributes', settingAttributes); // console.log('attributes', settingAttributes);
if (typeof HTMLElement !== 'undefined') {
class StrudelRepl extends HTMLElement { class StrudelRepl extends HTMLElement {
static observedAttributes = ['code', ...settingAttributes]; static observedAttributes = ['code', ...settingAttributes];
settings = initialSettings; settings = initialSettings;
@ -109,3 +110,4 @@ class StrudelRepl extends HTMLElement {
} }
customElements.define('strudel-editor', StrudelRepl); customElements.define('strudel-editor', StrudelRepl);
}