From e7af4d770652f83773166f1c7aa418a2e6c24955 Mon Sep 17 00:00:00 2001 From: Tan Li Hau Date: Tue, 29 Jun 2021 10:17:16 +0800 Subject: [PATCH] expose svelte/ssr which have noop for lifecycle events (#6416) --- .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 e21a94e698..911ff19cab 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 682f1d547a..316cfcb9b0 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 81fa24bd9f..b60423c35c 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 0000000000..c75bb30349 --- /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() {}