You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
I'm building Sapper Studio, a GUI for creating Sapper apps (it'll make more sense when I share it soon, I promise), and it's revealed a limitation of the current setup — we can only get information about what Sapper is actually doing (e.g. the server is listening, the client is being rebuilt etc) via the process' stdout, which isn't very useful.
If there was an API that the CLI used internally, it would make it much easier to build clients like Sapper Studio.
Something like this:
Dev
import{dev}from'sapper/api.js';constwatcher=dev({// TODO not sure what options we need off the top of my head});watcher.on('invalidate',event=>{consttoRebuild=[event.invalid.client&&'client',event.invalid.server&&'server',event.invalid.serviceworker&&'service worker'].filter(Boolean);console.log(`${event.file} changed. rebuilding ${toRebuild.join(', ')}`);});watcher.on('build',event=>{console.log(`rebuilt ${event.type} in ${prettyMs(event.duration)}`);if(event.warnings.length){console.log(`${event.warnings.length} warnings:`);event.warnings.forEach(warning=>{console.log(warning.toString());});}});watcher.on('error',event=>{console.log(`an error occurred building the ${event.type}`:);console.log(event.error.message);});watcher.on('ready',event=>{console.log(`server listening on localhost:${event.port}`);});// later...watcher.close();
Build
import{build}from'sapper/api.js';constemitter=build({dest: 'build'// TODO see above});emitter.on('done',event=>{console.log(`built to ${event.dest} in ${prettyMs(event.duration)}`);// future version maybeconsole.log(prettyPrintStats(event.stats));});emitter.on('build',event=>{// fires for each individual build, so you can build a progress UIconsole.log(`built ${event.type} in ${prettyMs(event.duration)}`);if(event.warnings.length){console.log(`${event.warnings.length} warnings:`);event.warnings.forEach(warning=>{console.log(warning.toString());});}});emitter.on('error',event=>{// do something with the error});
Export
import{exporter}from'sapper/api.js';// basically the same as buildconstemitter=exporter({dest: 'www'// TODO see above});// ...
The text was updated successfully, but these errors were encountered:
Oh and I suppose the dev watcher needs to expose the child process' stdout/stderr. Two possibilities:
watcher.on('ready',event=>{console.log(`server listening on localhost:${event.port}`);event.process.stdout.on('data',data=>{process.stdout.write(data);});event.process.stderr.on('data',data=>{process.stderr.write(data);});});
I'm building Sapper Studio, a GUI for creating Sapper apps (it'll make more sense when I share it soon, I promise), and it's revealed a limitation of the current setup — we can only get information about what Sapper is actually doing (e.g. the server is listening, the client is being rebuilt etc) via the process'
stdout
, which isn't very useful.If there was an API that the CLI used internally, it would make it much easier to build clients like Sapper Studio.
Something like this:
Dev
Build
Export
The text was updated successfully, but these errors were encountered: