From 424455bcbbd8bf0e6c0bd826dfe86c0a4075ab12 Mon Sep 17 00:00:00 2001 From: tanhauhau Date: Sun, 20 Jun 2021 23:41:32 +0800 Subject: [PATCH] expose svelte/ssr which have noop for lifecycle events --- .gitignore | 1 + package.json | 4 ++++ rollup.config.js | 18 ++++++++++++++++++ src/runtime/ssr.ts | 14 ++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 src/runtime/ssr.ts diff --git a/.gitignore b/.gitignore index e21a94e698d9..911ff19cab26 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ node_modules /compiler.d.ts /compiler.*js /index.*js +/ssr.*js /internal /store /easing diff --git a/package.json b/package.json index d3bfe1438e44..f677581b2e02 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,10 @@ "./transition": { "import": "./transition/index.mjs", "require": "./transition/index.js" + }, + "./ssr": { + "import": "./ssr.mjs", + "require": "./ssr.js" } }, "engines": { diff --git a/rollup.config.js b/rollup.config.js index 81fa24bd9f08..b60423c35ca7 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -42,6 +42,24 @@ export default [ plugins: [ts_plugin] }, + { + input: `src/runtime/ssr.ts`, + output: [ + { + file: `ssr.mjs`, + format: 'esm', + paths: id => id.startsWith('svelte/') && `${id.replace('svelte', '.')}/index.mjs` + }, + { + file: `ssr.js`, + format: 'cjs', + paths: id => id.startsWith('svelte/') && `${id.replace('svelte', '.')}/index.js` + } + ], + external, + plugins: [ts_plugin] + }, + ...fs.readdirSync('src/runtime') .filter(dir => fs.statSync(`src/runtime/${dir}`).isDirectory()) .map(dir => ({ diff --git a/src/runtime/ssr.ts b/src/runtime/ssr.ts new file mode 100644 index 000000000000..c75bb3034935 --- /dev/null +++ b/src/runtime/ssr.ts @@ -0,0 +1,14 @@ +export { + setContext, + getContext, + hasContext, + tick, + createEventDispatcher, + SvelteComponent, + SvelteComponentTyped +} from './index'; + +export function onMount() {} +export function onDestroy() {} +export function beforeUpdate() {} +export function afterUpdate() {}