repl: use Rollup 1.x

pull/2210/head
Conduitry 7 years ago
parent 328db0920f
commit 78cb0183fb

@ -14,7 +14,7 @@ self.addEventListener('message', async event => {
version === 'local' ? version === 'local' ?
'/repl/local?file=compiler.js' : '/repl/local?file=compiler.js' :
`https://unpkg.com/svelte@${version}/compiler.js`, `https://unpkg.com/svelte@${version}/compiler.js`,
`https://unpkg.com/rollup@0.68/dist/rollup.browser.js` `https://unpkg.com/rollup@1/dist/rollup.browser.js`
); );
fulfil(); fulfil();
@ -62,7 +62,6 @@ function fetch_if_uncached(url) {
async function getBundle(mode, cache, lookup) { async function getBundle(mode, cache, lookup) {
let bundle; let bundle;
let error;
const all_warnings = []; const all_warnings = [];
const new_cache = {}; const new_cache = {};
@ -106,7 +105,7 @@ async function getBundle(mode, cache, lookup) {
: svelte.compile(code, Object.assign({ : svelte.compile(code, Object.assign({
generate: mode, generate: mode,
format: 'esm', format: 'esm',
name: name, name,
filename: name + '.svelte' filename: name + '.svelte'
}, commonCompilerOptions)); }, commonCompilerOptions));
@ -124,6 +123,7 @@ async function getBundle(mode, cache, lookup) {
return result.js; return result.js;
} }
}], }],
inlineDynamicImports: true,
onwarn(warning) { onwarn(warning) {
all_warnings.push({ all_warnings.push({
message: warning.message message: warning.message
@ -131,7 +131,7 @@ async function getBundle(mode, cache, lookup) {
} }
}); });
} catch (error) { } catch (error) {
return { error, bundle: null, cache: new_cache, warnings: all_warnings } return { error, bundle: null, cache: new_cache, warnings: all_warnings };
} }
return { bundle, cache: new_cache, error: null, warnings: all_warnings }; return { bundle, cache: new_cache, error: null, warnings: all_warnings };
@ -168,7 +168,7 @@ async function bundle(components) {
let uid = 1; let uid = 1;
const dom_result = await dom.bundle.generate({ const dom_result = (await dom.bundle.generate({
format: 'iife', format: 'iife',
name: 'SvelteComponent', name: 'SvelteComponent',
globals: id => { globals: id => {
@ -177,7 +177,7 @@ async function bundle(components) {
return name; return name;
}, },
sourcemap: true sourcemap: true
}); })).output[0];
if (token !== currentToken) return; if (token !== currentToken) return;
@ -195,16 +195,16 @@ async function bundle(components) {
if (token !== currentToken) return; if (token !== currentToken) return;
const ssr_result = ssr const ssr_result = ssr
? await ssr.bundle.generate({ ? (await ssr.bundle.generate({
format: 'iife', format: 'iife',
name: 'SvelteComponent', name: 'SvelteComponent',
globals: id => import_map.get(id), globals: id => import_map.get(id),
sourcemap: true sourcemap: true
}) })).output[0]
: null; : null;
return { return {
imports: dom.bundle.imports, imports: dom_result.imports,
import_map, import_map,
dom: dom_result, dom: dom_result,
ssr: ssr_result, ssr: ssr_result,

Loading…
Cancel
Save