Skip to content

Commit f88c32f

Browse files
committed
update filename stuff
1 parent 78e7963 commit f88c32f

File tree

17 files changed

+27
-24
lines changed

17 files changed

+27
-24
lines changed

packages/svelte/src/compiler/phases/3-transform/client/transform-client.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,17 @@ export function client_component(source, analysis, options) {
348348

349349
if (options.dev) {
350350
if (options.filename) {
351+
let filename = options.filename;
352+
if (/(\/|\w:)/.test(options.filename)) {
353+
// filename is absolute — truncate it
354+
const parts = filename.split(/[/\\]/);
355+
filename = parts.length > 3 ? ['...', ...parts.slice(-3)].join('/') : filename;
356+
}
357+
351358
// add `App.filename = 'App.svelte'` so that we can print useful messages later
352359
body.push(
353360
b.stmt(
354-
b.assignment(
355-
'=',
356-
b.member(b.id(analysis.name), b.id('filename')),
357-
b.literal(options.filename)
358-
)
361+
b.assignment('=', b.member(b.id(analysis.name), b.id('filename')), b.literal(filename))
359362
)
360363
);
361364
}

packages/svelte/tests/helpers.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export async function compile_directory(
7373

7474
let text = fs.readFileSync(`${cwd}/${file}`, 'utf-8');
7575
let opts = {
76-
filename: file,
76+
filename: path.join(cwd, file),
7777
...compileOptions,
7878
generate
7979
};
@@ -86,7 +86,7 @@ export async function compile_directory(
8686
generate: opts.generate,
8787
dev: opts.dev
8888
});
89-
write(out, compiled.js.code);
89+
write(out, compiled.js.code.replace(`v${VERSION}`, 'VERSION'));
9090
} else {
9191
// for non-runes tests, just re-export from the original source file — this
9292
// allows the `_config.js` module to import shared state to use in tests
@@ -121,8 +121,8 @@ export async function compile_directory(
121121
}
122122

123123
const compiled = compile(text, {
124-
outputFilename: `_output/${generate}/${file}${file.endsWith('.js') ? '' : '.js'}`,
125-
cssOutputFilename: `_output/${generate}/${file}.css`,
124+
outputFilename: `${output_dir}/${file}${file.endsWith('.js') ? '' : '.js'}`,
125+
cssOutputFilename: `${output_dir}/${file}.css`,
126126
...opts
127127
});
128128
compiled.js.code = compiled.js.code.replace(`v${VERSION}`, 'VERSION');

packages/svelte/tests/runtime-runes/samples/non-local-mutation-discouraged/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default test({
4141
assert.htmlEqual(target.innerHTML, `<button>clicks: 1</button>`);
4242

4343
assert.deepEqual(warnings, [
44-
'Counter.svelte mutated a value owned by main.svelte. This is strongly discouraged. Consider passing values to child components with `bind:`, or use a callback instead.'
44+
'.../samples/non-local-mutation-discouraged/Counter.svelte mutated a value owned by .../samples/non-local-mutation-discouraged/main.svelte. This is strongly discouraged. Consider passing values to child components with `bind:`, or use a callback instead.'
4545
]);
4646
}
4747
});

packages/svelte/tests/snapshot/samples/bind-this/_expected/client/index.svelte.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import "svelte/internal/disclose-version";
44
import * as $ from "svelte/internal";
55

6-
export default function Index($$anchor, $$props) {
6+
export default function Bind_this($$anchor, $$props) {
77
$.push($$props, false);
88
$.init();
99

packages/svelte/tests/snapshot/samples/bind-this/_expected/server/index.svelte.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Note: compiler output will change before 5.0 is released!
33
import * as $ from "svelte/internal/server";
44

5-
export default function Index($$payload, $$props) {
5+
export default function Bind_this($$payload, $$props) {
66
$.push(false);
77

88
const anchor = $.create_anchor($$payload);

packages/svelte/tests/snapshot/samples/class-state-field-constructor-assignment/_expected/client/index.svelte.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import "svelte/internal/disclose-version";
44
import * as $ from "svelte/internal";
55

6-
export default function Index($$anchor, $$props) {
6+
export default function Class_state_field_constructor_assignment($$anchor, $$props) {
77
$.push($$props, true);
88

99
class Foo {

packages/svelte/tests/snapshot/samples/class-state-field-constructor-assignment/_expected/server/index.svelte.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Note: compiler output will change before 5.0 is released!
33
import * as $ from "svelte/internal/server";
44

5-
export default function Index($$payload, $$props) {
5+
export default function Class_state_field_constructor_assignment($$payload, $$props) {
66
$.push(true);
77

88
class Foo {

packages/svelte/tests/snapshot/samples/each-string-template/_expected/client/index.svelte.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import "svelte/internal/disclose-version";
44
import * as $ from "svelte/internal";
55

6-
export default function Index($$anchor, $$props) {
6+
export default function Each_string_template($$anchor, $$props) {
77
$.push($$props, false);
88
$.init();
99

packages/svelte/tests/snapshot/samples/each-string-template/_expected/server/index.svelte.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Note: compiler output will change before 5.0 is released!
33
import * as $ from "svelte/internal/server";
44

5-
export default function Index($$payload, $$props) {
5+
export default function Each_string_template($$payload, $$props) {
66
$.push(false);
77

88
const anchor = $.create_anchor($$payload);

packages/svelte/tests/snapshot/samples/function-prop-no-getter/_expected/client/index.svelte.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import "svelte/internal/disclose-version";
44
import * as $ from "svelte/internal";
55

6-
export default function Index($$anchor, $$props) {
6+
export default function Function_prop_no_getter($$anchor, $$props) {
77
$.push($$props, true);
88

99
let count = $.source(0);

packages/svelte/tests/snapshot/samples/function-prop-no-getter/_expected/server/index.svelte.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Note: compiler output will change before 5.0 is released!
33
import * as $ from "svelte/internal/server";
44

5-
export default function Index($$payload, $$props) {
5+
export default function Function_prop_no_getter($$payload, $$props) {
66
$.push(true);
77

88
let count = 0;

packages/svelte/tests/snapshot/samples/hello-world/_expected/client/index.svelte.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as $ from "svelte/internal";
55

66
var frag = $.template(`<h1>hello world</h1>`);
77

8-
export default function Index($$anchor, $$props) {
8+
export default function Hello_world($$anchor, $$props) {
99
$.push($$props, false);
1010
$.init();
1111

packages/svelte/tests/snapshot/samples/hello-world/_expected/server/index.svelte.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Note: compiler output will change before 5.0 is released!
33
import * as $ from "svelte/internal/server";
44

5-
export default function Index($$payload, $$props) {
5+
export default function Hello_world($$payload, $$props) {
66
$.push(false);
77
$$payload.out += `<h1>hello world</h1>`;
88
$.pop();

packages/svelte/tests/snapshot/samples/state-proxy-literal/_expected/client/index.svelte.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function reset(_, str, tpl) {
1212

1313
var frag = $.template(`<input> <input> <button>reset</button>`, true);
1414

15-
export default function Index($$anchor, $$props) {
15+
export default function State_proxy_literal($$anchor, $$props) {
1616
$.push($$props, true);
1717

1818
let str = $.source('');

packages/svelte/tests/snapshot/samples/state-proxy-literal/_expected/server/index.svelte.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Note: compiler output will change before 5.0 is released!
33
import * as $ from "svelte/internal/server";
44

5-
export default function Index($$payload, $$props) {
5+
export default function State_proxy_literal($$payload, $$props) {
66
$.push(true);
77

88
let str = '';

packages/svelte/tests/snapshot/samples/svelte-element/_expected/client/index.svelte.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import "svelte/internal/disclose-version";
44
import * as $ from "svelte/internal";
55

6-
export default function Index($$anchor, $$props) {
6+
export default function Svelte_element($$anchor, $$props) {
77
$.push($$props, true);
88

99
let tag = $.prop($$props, "tag", 3, 'hr');

packages/svelte/tests/snapshot/samples/svelte-element/_expected/server/index.svelte.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Note: compiler output will change before 5.0 is released!
33
import * as $ from "svelte/internal/server";
44

5-
export default function Index($$payload, $$props) {
5+
export default function Svelte_element($$payload, $$props) {
66
$.push(true);
77

88
let { tag = 'hr' } = $$props;

0 commit comments

Comments
 (0)