I totally get this is an edge case and that I should be using build tools, but is there a way to do this in a standalone way. (this is only for prototyping)
Ideally all the script refs are on unpkg already… cause that will play nicer with a CSP.
However, note that your sample code will still require transpilation as your HTML has JSX, and JSX isn’t valid JS – I guess tho that babel handles this somehow with that type=“text/babel”.
<script type="importmap">
"imports": {
"@ember/-internals/": "https://esm.sh/*ember-source/dist/packages/@ember/-internals/",
"@ember/template-compilation": "https://esm.sh/*ember-source/dist/packages/@ember/template-compilation"
// etc
}
</script>
<script type="module">
import { renderComponent } from '@ember/-internals/glimmer/lib/renderer'; // not final place
import { template } from '@ember/template-compilation'; // runtime compiler -- optimized further when you have a build step
import Application from '@ember/application';
import Registry from '@ember/-internals/container/lib/registry';
const HelloWorld = template(`
<div class="hello-world">
<h1>Hello, World!</h1>
<p>Welcome to Ember!</p>
</div>
`);
function buildOwner() {
// idk how much of this is needed
let registry = new Registry();
let owner = {
__registry__: registry,
__container__: null,
});
let container = registry.container({ owner: owner });
owner.__container__ = container;
return owner;
}
const root = document.getElementById('root');
const owner = buildOwner();
renderComponent(HelloWorld, {
owner, // allow injection and all that
env: {
document: document,
into: root,
// probably default?,
isInteractive: true,
}
})
</script>
this is just spit-ballin what I’m seeing in the PR – and we want the ergonomics of this to be much nicer.
Like, we need a better way for folks to get their first / top-level owner.
yes this is very much in line with what I want, are these libs on jsdelivr or some other big public CDN.
A big thing I want to avoid is needing to redistribute the libs.
Is the system prompt for ember assistant available somewhere public?
End result will be something like “ember assistant” except that you get to interact with the artifact live and right away and get to use any LLM you want, we run a few here.
It is not a strong requirement, but the way I have discourse-ai set up our artifact system is incredibly lightweight for people that use it. When I share an artifact like this one for example, I don’t need to worry about cost to me… all I pay is rendering of a tiny HTML page, the rest is being footed by cloudflare and other big web benefactors.
If I were to introduce build tools and so on into the stack it would complicate stuff… that said, if the payloads can remain small enough I could swing something as long as the fat dependencies like ember/etc remain off site.
We already run V8 and have access to ember-cli from Discourse so maybe if it was structured as: