chore: upgrade rollup (#8491)

bump to rollup 3. Includes reworking the "treat those imports as external" a bit so that Rollup builds correctly but doesn't bundle some of the (now relative) imports

---------

Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>
pull/8515/head
Ben McCann 1 year ago committed by Simon Holthausen
parent 99b6a25d9d
commit 2813814396

683
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -121,12 +121,12 @@
"devDependencies": {
"@ampproject/remapping": "^2.2.1",
"@jridgewell/sourcemap-codec": "^1.4.15",
"@rollup/plugin-commonjs": "^11.0.0",
"@rollup/plugin-commonjs": "^24.1.0",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^11.2.1",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-sucrase": "^3.1.0",
"@rollup/plugin-typescript": "^2.0.1",
"@rollup/plugin-sucrase": "^5.0.1",
"@rollup/plugin-typescript": "^11.1.0",
"@rollup/plugin-virtual": "^3.0.1",
"@sveltejs/eslint-config": "github:sveltejs/eslint-config#v5.8.0",
"@types/aria-query": "^5.0.1",
@ -152,7 +152,7 @@
"mocha": "^10.2.0",
"periscopic": "^3.1.0",
"puppeteer": "^19.8.5",
"rollup": "^1.27.14",
"rollup": "^3.20.2",
"source-map": "^0.7.4",
"source-map-support": "^0.5.21",
"tiny-glob": "^0.2.9",

@ -1,24 +1,58 @@
import fs from 'fs';
import fs from 'node:fs';
import { createRequire } from 'node:module';
import replace from '@rollup/plugin-replace';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import sucrase from '@rollup/plugin-sucrase';
import typescript from '@rollup/plugin-typescript';
import pkg from './package.json';
const require = createRequire(import.meta.url);
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
const is_publish = !!process.env.PUBLISH;
const ts_plugin = is_publish
? typescript({
include: 'src/**',
typescript: require('typescript')
})
: sucrase({
transforms: ['typescript']
});
const external = id => id.startsWith('svelte/');
// The following external and path logic is necessary so that the bundled runtime pieces and the index file
// reference each other correctly instead of bundling their references to each other
/**
* Ensures that relative imports inside `src/runtime` like `./internal` and `../store` are externalized correctly
*/
const external = (id, parent_id) => {
const parent_segments = parent_id.replace(/\\/g, '/').split('/');
// TODO needs to be adjusted when we move to JS modules
if (parent_segments[parent_segments.length - 3] === 'runtime') {
return /\.\.\/\w+$/.test(id);
} else {
return id === './internal' && parent_segments[parent_segments.length - 2] === 'runtime';
}
}
/**
* Transforms externalized import paths like `../store` into correct relative imports with correct index file extension import
*/
const replace_relative_svelte_imports = (id, ending) => {
id = id.replace(/\\/g, '/');
// TODO needs to be adjusted when we move to JS modules
return /src\/runtime\/\w+$/.test(id) && `../${id.split('/').pop()}/${ending}`;
}
/**
* Transforms externalized `./internal` import path into correct relative import with correct index file extension import
*/
const replace_relative_internal_import = (id, ending) => {
id = id.replace(/\\/g, '/');
// TODO needs to be adjusted when we move to JS modules
return id.endsWith('src/runtime/internal') && `./internal/${ending}`;
}
fs.writeFileSync(`./compiler.d.ts`, `export { compile, parse, preprocess, walk, VERSION } from './types/compiler/index';`);
@ -30,12 +64,12 @@ export default [
{
file: `index.mjs`,
format: 'esm',
paths: id => id.startsWith('svelte/') && `${id.replace('svelte', '.')}/index.mjs`
paths: id => replace_relative_internal_import(id, 'index.mjs')
},
{
file: `index.js`,
format: 'cjs',
paths: id => id.startsWith('svelte/') && `${id.replace('svelte', '.')}/index.js`
paths: id => replace_relative_internal_import(id, 'index.js')
}
],
external,
@ -48,12 +82,12 @@ export default [
{
file: `ssr.mjs`,
format: 'esm',
paths: id => id.startsWith('svelte/') && `${id.replace('svelte', '.')}/index.mjs`
paths: id => replace_relative_internal_import(id, 'index.mjs')
},
{
file: `ssr.js`,
format: 'cjs',
paths: id => id.startsWith('svelte/') && `${id.replace('svelte', '.')}/index.js`
paths: id => replace_relative_internal_import(id, 'index.js')
}
],
external,
@ -68,12 +102,12 @@ export default [
{
file: `${dir}/index.mjs`,
format: 'esm',
paths: id => id.startsWith('svelte/') && `${id.replace('svelte', '..')}/index.mjs`
paths: id => replace_relative_svelte_imports(id, 'index.mjs')
},
{
file: `${dir}/index.js`,
format: 'cjs',
paths: id => id.startsWith('svelte/') && `${id.replace('svelte', '..')}/index.js`
paths: id => replace_relative_svelte_imports(id, 'index.js')
}
],
external,
@ -83,7 +117,7 @@ export default [
}),
ts_plugin,
{
writeBundle(bundle) {
writeBundle(_options, bundle) {
if (dir === 'internal') {
const mod = bundle['index.mjs'];
if (mod) {

@ -1,5 +1,5 @@
import { cubicOut } from 'svelte/easing';
import { is_function } from 'svelte/internal';
import { cubicOut } from '../easing';
import { is_function } from '../internal';
// todo: same as Transition, should it be shared?
export interface AnimationConfig {

@ -3,7 +3,7 @@ Adapted from https://github.com/mattdesl
Distributed under MIT License https://github.com/mattdesl/eases/blob/master/LICENSE.md
*/
export { identity as linear } from 'svelte/internal';
export { identity as linear } from '../internal';
export function backInOut(t: number) {
const s = 1.70158 * 1.525;

@ -13,5 +13,5 @@ export {
createEventDispatcher,
SvelteComponentDev as SvelteComponent,
SvelteComponentTyped
} from 'svelte/internal';
export type { ComponentType, ComponentConstructorOptions, ComponentProps, ComponentEvents } from 'svelte/internal';
} from './internal';
export type { ComponentType, ComponentConstructorOptions, ComponentProps, ComponentEvents } from './internal';

@ -1,4 +1,4 @@
import { Readable } from 'svelte/store';
import type { Readable } from '../store';
export function noop() {}

@ -1,5 +1,5 @@
import { Readable, writable } from 'svelte/store';
import { loop, now, Task } from 'svelte/internal';
import { Readable, writable } from '../store';
import { loop, now, Task } from '../internal';
import { is_date } from './utils';
interface TickContext<T> {

@ -1,6 +1,6 @@
import { Readable, writable } from 'svelte/store';
import { assign, loop, now, Task } from 'svelte/internal';
import { linear } from 'svelte/easing';
import { Readable, writable } from '../store';
import { assign, loop, now, Task } from '../internal';
import { linear } from '../easing';
import { is_date } from './utils';
function get_interpolator(a, b) {

@ -1,4 +1,4 @@
import { run_all, subscribe, noop, safe_not_equal, is_function, get_store_value } from 'svelte/internal';
import { run_all, subscribe, noop, safe_not_equal, is_function, get_store_value } from '../internal';
/** Callback to inform of a value updates. */
export type Subscriber<T> = (value: T) => void;

@ -1,5 +1,5 @@
import { cubicOut, cubicInOut, linear } from 'svelte/easing';
import { assign, split_css_unit, is_function } from 'svelte/internal';
import { cubicOut, cubicInOut, linear } from '../easing';
import { assign, split_css_unit, is_function } from '../internal';
export type EasingFunction = (t: number) => number;

@ -1,12 +1,12 @@
{
"include": [],
"include": ["src/**/*"],
"compilerOptions": {
"rootDir": "src",
// target node v8+ (https://node.green/)
// the only missing feature is Array.prototype.values
"lib": ["es2017", "DOM"],
"lib": ["es2017", "DOM", "DOM.Iterable"],
"target": "es2017",
"declaration": true,

Loading…
Cancel
Save