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,4 +1,4 @@
<script src="https://unpkg.com/@strudel/repl@0.9.4"></script> <script src="https://unpkg.com/@strudel/repl@1.0.2"></script>
<strudel-editor> <strudel-editor>
<!-- <!--
// @date 23-08-15 // @date 23-08-15

View File

@ -0,0 +1,8 @@
<script src="https://unpkg.com/@strudel/web@1.0.3"></script>
<button id="play">PLAY</button>
<script>
initStrudel({
prebake: () => samples('github:tidalcycles/dirt-samples'),
});
document.getElementById('play').addEventListener('click', () => s('bd sd').play());
</script>

View File

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

View File

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

View File

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

6
pnpm-lock.yaml generated
View File

@ -430,6 +430,9 @@ importers:
packages/web: packages/web:
dependencies: dependencies:
'@rollup/plugin-replace':
specifier: ^5.0.5
version: 5.0.5
'@strudel/core': '@strudel/core':
specifier: workspace:* specifier: workspace:*
version: link:../core version: link:../core
@ -3691,7 +3694,6 @@ packages:
dependencies: dependencies:
'@rollup/pluginutils': 5.1.0 '@rollup/pluginutils': 5.1.0
magic-string: 0.30.5 magic-string: 0.30.5
dev: true
/@rollup/pluginutils@3.1.0(rollup@2.79.1): /@rollup/pluginutils@3.1.0(rollup@2.79.1):
resolution: {integrity: sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==} resolution: {integrity: sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==}
@ -3717,7 +3719,6 @@ packages:
'@types/estree': 1.0.0 '@types/estree': 1.0.0
estree-walker: 2.0.2 estree-walker: 2.0.2
picomatch: 2.3.1 picomatch: 2.3.1
dev: true
/@rollup/rollup-android-arm-eabi@4.9.2: /@rollup/rollup-android-arm-eabi@4.9.2:
resolution: {integrity: sha512-RKzxFxBHq9ysZ83fn8Iduv3A283K7zPPYuhL/z9CQuyFrjwpErJx0h4aeb/bnJ+q29GRLgJpY66ceQ/Wcsn3wA==} resolution: {integrity: sha512-RKzxFxBHq9ysZ83fn8Iduv3A283K7zPPYuhL/z9CQuyFrjwpErJx0h4aeb/bnJ+q29GRLgJpY66ceQ/Wcsn3wA==}
@ -7118,7 +7119,6 @@ packages:
/estree-walker@2.0.2: /estree-walker@2.0.2:
resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==} resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==}
dev: true
/estree-walker@3.0.3: /estree-walker@3.0.3:
resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==}