diff --git a/rollup.config.js b/rollup.config.js index 0d19e59d4a..6f9601644b 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -94,26 +94,21 @@ export default [ { file: `store.mjs`, format: 'esm', - paths: id => id.startsWith('svelte/') && id.replace('svelte', '.') }, { file: `store.js`, format: 'cjs', - paths: id => id.startsWith('svelte/') && id.replace('svelte', '.') } ], plugins: [ is_publish ? typescript({ - include: 'src/**', - exclude: 'src/internal/**', typescript: require('typescript') }) : sucrase({ transforms: ['typescript'] }) - ], - external: id => id.startsWith('svelte/') + ] }, // everything else diff --git a/src/store.ts b/src/store.ts index b0ee41fc8d..858af53347 100644 --- a/src/store.ts +++ b/src/store.ts @@ -1,4 +1,10 @@ -import { run_all, noop, safe_not_equal, is_function } from './internal/utils'; +/** Safe not equal. */ +function safe_not_equal(a: any, b: any) { + return a !== a ? b === b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); +} + +/** No operation. */ +function noop() { } /** Callback to inform of a value updates. */ type Subscriber = (value: T) => void; @@ -143,7 +149,7 @@ export function derived( if (auto) { set(result as T); } else { - cleanup = is_function(result) ? result as Unsubscriber : noop; + cleanup = result instanceof Function ? result as Unsubscriber : noop; } }; @@ -164,7 +170,7 @@ export function derived( sync(); return function stop() { - run_all(unsubscribers); + unsubscribers.forEach((unsubscribe) => unsubscribe()); cleanup(); }; });