Open mizchi opened 3 years ago
can you please post the svelte output?
Source
<script>
import { onMount } from "svelte"
let name = 'world';
onMount(() => {
console.log('mounted');
})
</script>
<h1>Hello {name}!</h1>
Output
/* App.svelte generated by Svelte v3.31.2 */
import {
SvelteComponent,
detach,
element,
init,
insert,
noop,
safe_not_equal
} from "svelte/internal";
import { onMount } from "svelte";
function create_fragment(ctx) {
let h1;
return {
c() {
h1 = element("h1");
h1.textContent = `Hello ${name}!`;
},
m(target, anchor) {
insert(target, h1, anchor);
},
p: noop,
i: noop,
o: noop,
d(detaching) {
if (detaching) detach(h1);
}
};
}
let name = "world";
function instance($$self) {
onMount(() => {
console.log("mounted");
});
return [];
}
class App extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, {});
}
}
export default App;
I added rollup plugin to rewrite specifiers like svelte
=> https://esm.sh/svelte
and svelte/internal
https://esm.sh/svelte/internal
and download it https://github.com/mizchi/uniroll/tree/master/packages/rollup-plugin-http-resolve
you can try here https://svelte.dev/repl/hello-world?version=3.31.2
@ije the main store of the library isn't shared between both dependencies. Is there a way to fix this?
currenlty needs to declares the exports
in package.json then esm.sh can split the code, for example:
{
"name": "svelte",
"exports": {
"./internal": { "import": "...", "require": "...." }
}
}
but i think i can add a workaround just for svelte
@ije Can you help me write a more specific example?
@ije we have a library that's modularized into different packages. All packages share the same store, but this communication seems to get lost when importing the different packages with esm.sh
@ije Any update on this?
does means "svelte" equals to epxort * from "svelte/internal"
i think i have fixed it, but didn't deploy the patch yet
the "svelte" will import "./internal" instaed of bundling it
i'm still working on v136, will deploy the change soon
Hi there, will v136 also help/fix #741
I found some patterns.
Example
preact case
svelte case.
compiled svelte has
import { ... } from "svelte/internal"
.To be common to both, they have to share the same instance in its inside. esm.sh failed.
(skypack works in these cases)