Skip to content

Commit 5161dfb

Browse files
committed
update folder structure - sveltejs#2790
1 parent b0b86f7 commit 5161dfb

File tree

184 files changed

+112
-120
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+112
-120
lines changed

.gitignore

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ node_modules
55
*.map
66
/src/compile/internal-exports.ts
77
/compiler.*js
8-
/index.*js
9-
/internal.*js
10-
/store.*js
11-
/easing.*js
12-
/motion.*js
13-
/transition.*js
14-
/animate.*js
8+
/index
9+
/internal
10+
/store
11+
/easing
12+
/motion
13+
/transition
14+
/animate
1515
/scratch/
1616
/coverage/
1717
/coverage.lcov/

animate.d.ts

-1
This file was deleted.

easing.d.ts

-1
This file was deleted.

index.d.ts

-1
This file was deleted.

index.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, '__esModule', { value: true });
4+
5+
var internal = require('./internal');
6+
7+
8+
9+
exports.onMount = internal.onMount;
10+
exports.onDestroy = internal.onDestroy;
11+
exports.beforeUpdate = internal.beforeUpdate;
12+
exports.afterUpdate = internal.afterUpdate;
13+
exports.setContext = internal.setContext;
14+
exports.getContext = internal.getContext;
15+
exports.tick = internal.tick;
16+
exports.createEventDispatcher = internal.createEventDispatcher;

index.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { onMount, onDestroy, beforeUpdate, afterUpdate, setContext, getContext, tick, createEventDispatcher } from './internal';

internal.d.ts

-1
This file was deleted.

motion.d.ts

-1
This file was deleted.

package.json

+10-8
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@
99
"compiler.js",
1010
"register.js",
1111
"index.*",
12-
"internal.*",
13-
"store.*",
14-
"animate.*",
15-
"transition.*",
16-
"easing.*",
17-
"motion.*",
12+
"internal",
13+
"store",
14+
"animate",
15+
"transition",
16+
"easing",
17+
"motion",
1818
"svelte",
1919
"README.md"
2020
],
21+
"types": "types/runtime",
2122
"scripts": {
2223
"test": "mocha --opts mocha.opts",
2324
"test:unit": "mocha --require sucrase/register --recursive ./**/__test__.ts",
@@ -30,8 +31,9 @@
3031
"prepare": "npm run build && npm run tsd",
3132
"dev": "rollup -cw",
3233
"pretest": "npm run build",
33-
"posttest": "agadoo internal.mjs",
34-
"prepublishOnly": "export PUBLISH=true && npm test",
34+
"posttest": "agadoo internal/index.mjs",
35+
"prepublishOnly": "export PUBLISH=true && npm test && npm run create-stubs",
36+
"create-stubs": "node scripts/create-stubs.js",
3537
"tsd": "tsc -p . --emitDeclarationOnly",
3638
"typecheck": "tsc -p . --noEmit"
3739
},

rollup.config.js

+32-62
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import pkg from './package.json';
99

1010
const is_publish = !!process.env.PUBLISH;
1111

12-
const tsPlugin = is_publish
12+
const ts_plugin = is_publish
1313
? typescript({
1414
include: 'src/**',
1515
typescript: require('typescript')
@@ -18,39 +18,12 @@ const tsPlugin = is_publish
1818
transforms: ['typescript']
1919
});
2020

21-
export default [
22-
/* internal.[m]js */
23-
{
24-
input: `src/internal/index.ts`,
25-
output: [
26-
{
27-
file: `internal.mjs`,
28-
format: 'esm',
29-
paths: id => id.startsWith('svelte/') && id.replace('svelte', '.')
30-
},
31-
{
32-
file: `internal.js`,
33-
format: 'cjs',
34-
paths: id => id.startsWith('svelte/') && id.replace('svelte', '.')
35-
}
36-
],
37-
external: id => id.startsWith('svelte/'),
38-
39-
plugins: [
40-
tsPlugin,
41-
{
42-
generateBundle(options, bundle) {
43-
const mod = bundle['internal.mjs'];
44-
if (mod) {
45-
fs.writeFileSync('src/compile/internal-exports.ts', `// This file is automatically generated\nexport default new Set(${JSON.stringify(mod.exports)});`);
46-
}
47-
}
48-
}]
49-
},
21+
const external = id => id.startsWith('svelte/');
5022

23+
export default [
5124
/* compiler.js */
5225
{
53-
input: 'src/compiler.ts',
26+
input: 'src/compiler/index.ts',
5427
plugins: [
5528
replace({
5629
__VERSION__: pkg.version
@@ -60,7 +33,7 @@ export default [
6033
include: ['node_modules/**']
6134
}),
6235
json(),
63-
tsPlugin
36+
ts_plugin
6437
],
6538
output: {
6639
file: 'compiler.js',
@@ -73,45 +46,42 @@ export default [
7346
: id => id === 'acorn' || id === 'magic-string' || id.startsWith('css-tree')
7447
},
7548

76-
/* motion.mjs */
49+
/* runtime */
7750
{
78-
input: `src/motion/index.ts`,
51+
input: `src/runtime/index.ts`,
7952
output: [
8053
{
81-
file: `motion.mjs`,
54+
file: `index.mjs`,
8255
format: 'esm',
83-
paths: id => id.startsWith('svelte/') && id.replace('svelte', '.')
56+
paths: id => id.startsWith('svelte/') && `${id.replace('svelte', '.')}`
8457
},
8558
{
86-
file: `motion.js`,
59+
file: `index.js`,
8760
format: 'cjs',
88-
paths: id => id.startsWith('svelte/') && id.replace('svelte', '.')
61+
paths: id => id.startsWith('svelte/') && `${id.replace('svelte', '.')}`
8962
}
9063
],
91-
plugins: [
92-
tsPlugin
93-
],
94-
external: id => id.startsWith('svelte/')
64+
external,
65+
plugins: [ts_plugin]
9566
},
9667

97-
// everything else
98-
...['index', 'easing', 'transition', 'animate', 'store'].map(name => ({
99-
input: `src/${name}.ts`,
100-
output: [
101-
{
102-
file: `${name}.mjs`,
103-
format: 'esm',
104-
paths: id => id.startsWith('svelte/') && id.replace('svelte', '.')
105-
},
106-
{
107-
file: `${name}.js`,
108-
format: 'cjs',
109-
paths: id => id.startsWith('svelte/') && id.replace('svelte', '.')
110-
}
111-
],
112-
plugins: [
113-
tsPlugin
114-
],
115-
external: id => id.startsWith('svelte/')
116-
}))
68+
...fs.readdirSync('src/runtime')
69+
.filter(dir => fs.statSync(`src/runtime/${dir}`).isDirectory())
70+
.map(dir => ({
71+
input: `src/runtime/${dir}/index.ts`,
72+
output: [
73+
{
74+
file: `${dir}/index.mjs`,
75+
format: 'esm',
76+
paths: id => id.startsWith('svelte/') && `${id.replace('svelte', '..')}`
77+
},
78+
{
79+
file: `${dir}/index.js`,
80+
format: 'cjs',
81+
paths: id => id.startsWith('svelte/') && `${id.replace('svelte', '..')}`
82+
}
83+
],
84+
external,
85+
plugins: [ts_plugin]
86+
}))
11787
];

scripts/create-stubs.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const fs = require('fs');
2+
3+
fs.readdirSync('src/runtime')
4+
.filter(dir => fs.statSync(`src/runtime/${dir}`).isDirectory())
5+
.forEach(dir => {
6+
fs.writeFileSync(`${dir}/package.json`, JSON.stringify({
7+
main: './index.js',
8+
module: './index.mjs'
9+
}, null, ' '));
10+
11+
fs.writeFileSync(`${dir}/index.d.ts`, `export * from '../types/runtime/${dir}/index.d.ts';`);
12+
});

src/Stats.ts src/compiler/Stats.ts

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/compile/index.ts src/compiler/compile/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assign } from '../internal/index';
1+
import { assign } from '../../runtime/internal/index';
22
import Stats from '../Stats';
33
import parse from '../parse/index';
44
import render_dom from './render-dom/index';
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// This file is automatically generated
2+
export default new Set(["create_animation","fix_position","handle_promise","append","insert","detach","detach_between","detach_before","detach_after","destroy_each","element","object_without_properties","svg_element","text","space","empty","listen","prevent_default","stop_propagation","attr","set_attributes","set_custom_element_data","xlink_attr","get_binding_group_value","to_number","time_ranges_to_array","children","claim_element","claim_text","set_data","set_input_type","set_style","select_option","select_options","select_value","select_multiple_value","add_resize_listener","toggle_class","custom_event","destroy_block","outro_and_destroy_block","fix_and_outro_and_destroy_block","update_keyed_each","measure","current_component","set_current_component","beforeUpdate","onMount","afterUpdate","onDestroy","createEventDispatcher","setContext","getContext","bubble","clear_loops","loop","dirty_components","intros","schedule_update","tick","add_binding_callback","add_render_callback","add_flush_callback","flush","get_spread_update","invalid_attribute_name_character","spread","escaped","escape","each","missing_component","validate_component","debug","create_ssr_component","get_store_value","group_outros","check_outros","on_outro","create_in_transition","create_out_transition","create_bidirectional_transition","noop","identity","assign","is_promise","add_location","run","blank_object","run_all","is_function","safe_not_equal","not_equal","validate_store","subscribe","create_slot","get_slot_context","get_slot_changes","exclude_internal_props","now","raf","set_now","set_raf","bind","mount_component","init","SvelteElement","SvelteComponent","SvelteComponentDev"]);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/compile/nodes/shared/AbstractBlock.ts src/compiler/compile/nodes/shared/AbstractBlock.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Block from '../../render-dom/Block';
2-
import Component from './../../Component';
2+
import Component from '../../Component';
33
import Node from './Node';
44
import { INode } from '../interfaces';
55

src/compile/nodes/shared/Node.ts src/compiler/compile/nodes/shared/Node.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import Attribute from './../Attribute';
2-
import Component from './../../Component';
1+
import Attribute from '../Attribute';
2+
import Component from '../../Component';
33
import { INode } from '../interfaces';
44
import Text from '../Text';
55

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/compile/render-dom/wrappers/Element/Binding.ts src/compiler/compile/render-dom/wrappers/Element/Binding.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Binding from '../../../nodes/Binding';
2-
import ElementWrapper from '.';
2+
import ElementWrapper from '../Element';
33
import { dimensions } from '../../../../utils/patterns';
44
import get_object from '../../../utils/get_object';
55
import Block from '../../Block';

src/compile/render-dom/wrappers/Element/StyleAttribute.ts src/compiler/compile/render-dom/wrappers/Element/StyleAttribute.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Attribute from '../../../nodes/Attribute';
22
import Block from '../../Block';
33
import AttributeWrapper from './Attribute';
4-
import ElementWrapper from '.';
4+
import ElementWrapper from '../Element';
55
import { stringify } from '../../../utils/stringify';
66
import add_to_set from '../../../utils/add_to_set';
77
import Expression from '../../../nodes/shared/Expression';
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/utils/error.ts src/compiler/utils/error.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { locate } from 'locate-character';
2-
import get_code_frame from '../utils/get_code_frame';
2+
import get_code_frame from './get_code_frame';
33

44
class CompileError extends Error {
55
code: string;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/index.ts src/runtime/index.ts

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

store.d.ts

-1
This file was deleted.

test/custom-elements/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('custom-elements', function() {
5858

5959
const solo = /\.solo$/.test(dir);
6060
const skip = /\.skip$/.test(dir);
61-
const internal = path.resolve('internal.mjs');
61+
const internal = path.resolve('internal/index.mjs');
6262
const index = path.resolve('index.mjs');
6363
const warnings = [];
6464

@@ -71,7 +71,7 @@ describe('custom-elements', function() {
7171
plugins: [
7272
{
7373
resolveId(importee) {
74-
if (importee === 'svelte/internal') {
74+
if (importee === 'svelte/internal' || importee === './internal') {
7575
return internal;
7676
}
7777

test/runtime/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as path from "path";
33
import * as fs from "fs";
44
import { rollup } from 'rollup';
55
import * as virtual from 'rollup-plugin-virtual';
6-
import { clear_loops, set_now, set_raf } from "../../internal.js";
6+
import { clear_loops, set_now, set_raf } from "../../internal";
77

88
import {
99
showOutput,
@@ -20,7 +20,7 @@ let compileOptions = null;
2020
let compile = null;
2121

2222
const sveltePath = process.cwd().split('\\').join('/');
23-
const internal = `${sveltePath}/internal.js`;
23+
const internal = `${sveltePath}/internal`;
2424

2525
describe("runtime", () => {
2626
before(() => {
@@ -223,7 +223,7 @@ describe("runtime", () => {
223223
{
224224
resolveId: (importee, importer) => {
225225
if (importee.startsWith('svelte/')) {
226-
return importee.replace('svelte', process.cwd()) + '.mjs';
226+
return importee.replace('svelte', process.cwd()) + '/index.mjs';
227227
}
228228
}
229229
}

test/runtime/samples/prop-subscribable/_config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { writable } from '../../../../store.js';
1+
import { writable } from '../../../../store';
22

33
export default {
44
props: {

test/runtime/samples/store-assignment-updates-reactive/_config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { writable } from '../../../../store.js';
1+
import { writable } from '../../../../store';
22

33
const c = writable(0);
44

test/runtime/samples/store-assignment-updates-reactive/main.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
import { writable } from '../../../../store.js';
2+
import { writable } from '../../../../store';
33
44
const a = writable();
55
const b = writable();

test/runtime/samples/store-assignment-updates/_config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { writable } from '../../../../store.js';
1+
import { writable } from '../../../../store';
22

33
export default {
44
props: {

test/runtime/samples/store-auto-subscribe-implicit/_config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { writable } from '../../../../store.js';
1+
import { writable } from '../../../../store';
22

33
export default {
44
props: {

test/runtime/samples/store-auto-subscribe-in-each/_config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { writable } from '../../../../store.js';
1+
import { writable } from '../../../../store';
22

33
export default {
44
skip: true,

test/runtime/samples/store-auto-subscribe-in-reactive-declaration/_config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { writable } from '../../../../store.js';
1+
import { writable } from '../../../../store';
22

33
export default {
44
props: {

test/runtime/samples/store-auto-subscribe-in-script/_config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { writable } from '../../../../store.js';
1+
import { writable } from '../../../../store';
22

33
const count = writable(0);
44

test/runtime/samples/store-auto-subscribe/_config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { writable } from '../../../../store.js';
1+
import { writable } from '../../../../store';
22

33
export default {
44
props: {

test/runtime/samples/store-contextual/_config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { writable } from '../../../../store.js';
1+
import { writable } from '../../../../store';
22

33
const todos = [
44
writable({ done: false, text: 'write docs' }),
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import { writable } from '../../../../store.js';
1+
import { writable } from '../../../../store';
22

33
export default writable(42);

0 commit comments

Comments
 (0)