-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] resolve $lib alias when packaging
Fixes the 90% case of #1950
- Loading branch information
Simon Holthausen
committed
Sep 17, 2021
1 parent
4f748a9
commit e3bada8
Showing
23 changed files
with
181 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
Resolve \$lib alias when packaging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
packages/kit/src/packaging/test/fixtures/resolve-alias/expected/Test.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<script lang="ts"> | ||
import { foo } from './sub/foo'; | ||
export let bar = foo; | ||
</script> |
15 changes: 15 additions & 0 deletions
15
packages/kit/src/packaging/test/fixtures/resolve-alias/expected/Test.svelte.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { SvelteComponentTyped } from 'svelte'; | ||
declare const __propDef: { | ||
props: { | ||
bar?: import('./sub/foo').Foo; | ||
}; | ||
events: { | ||
[evt: string]: CustomEvent<any>; | ||
}; | ||
slots: {}; | ||
}; | ||
export declare type TestProps = typeof __propDef.props; | ||
export declare type TestEvents = typeof __propDef.events; | ||
export declare type TestSlots = typeof __propDef.slots; | ||
export default class Test extends SvelteComponentTyped<TestProps, TestEvents, TestSlots> {} | ||
export {}; |
4 changes: 4 additions & 0 deletions
4
packages/kit/src/packaging/test/fixtures/resolve-alias/expected/baz.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface Baz { | ||
baz: string; | ||
} | ||
export declare const baz: Baz; |
1 change: 1 addition & 0 deletions
1
packages/kit/src/packaging/test/fixtures/resolve-alias/expected/baz.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const baz = { baz: 'baz' }; |
1 change: 1 addition & 0 deletions
1
packages/kit/src/packaging/test/fixtures/resolve-alias/expected/index.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as Test } from './Test.svelte'; |
1 change: 1 addition & 0 deletions
1
packages/kit/src/packaging/test/fixtures/resolve-alias/expected/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as Test } from './Test.svelte'; |
14 changes: 14 additions & 0 deletions
14
packages/kit/src/packaging/test/fixtures/resolve-alias/expected/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "resolve-alias", | ||
"version": "1.0.0", | ||
"description": "package using $lib alias", | ||
"type": "module", | ||
"exports": { | ||
"./package.json": "./package.json", | ||
"./Test.svelte": "./Test.svelte", | ||
".": "./index.js", | ||
"./baz": "./baz.js", | ||
"./sub/bar": "./sub/bar.js", | ||
"./sub/foo": "./sub/foo.js" | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/kit/src/packaging/test/fixtures/resolve-alias/expected/sub/bar.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export declare const bar1: import('./foo').Foo; | ||
export declare const bar2: import('../baz').Baz; |
4 changes: 4 additions & 0 deletions
4
packages/kit/src/packaging/test/fixtures/resolve-alias/expected/sub/bar.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { baz } from '../baz'; | ||
import { foo } from './foo'; | ||
export const bar1 = foo; | ||
export const bar2 = baz; |
4 changes: 4 additions & 0 deletions
4
packages/kit/src/packaging/test/fixtures/resolve-alias/expected/sub/foo.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface Foo { | ||
foo: string; | ||
} | ||
export declare const foo: Foo; |
1 change: 1 addition & 0 deletions
1
packages/kit/src/packaging/test/fixtures/resolve-alias/expected/sub/foo.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const foo = { foo: 'foo' }; |
5 changes: 5 additions & 0 deletions
5
packages/kit/src/packaging/test/fixtures/resolve-alias/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "resolve-alias", | ||
"version": "1.0.0", | ||
"description": "package using $lib alias" | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/kit/src/packaging/test/fixtures/resolve-alias/src/app.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
%svelte.head% | ||
</head> | ||
<body> | ||
<div id="svelte">%svelte.body%</div> | ||
</body> | ||
</html> |
5 changes: 5 additions & 0 deletions
5
packages/kit/src/packaging/test/fixtures/resolve-alias/src/lib/Test.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script lang="ts"> | ||
import { foo } from '$lib/sub/foo'; | ||
export let bar = foo; | ||
</script> |
5 changes: 5 additions & 0 deletions
5
packages/kit/src/packaging/test/fixtures/resolve-alias/src/lib/baz.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface Baz { | ||
baz: string; | ||
} | ||
|
||
export const baz: Baz = { baz: 'baz' }; |
1 change: 1 addition & 0 deletions
1
packages/kit/src/packaging/test/fixtures/resolve-alias/src/lib/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as Test } from '$lib/Test.svelte'; |
5 changes: 5 additions & 0 deletions
5
packages/kit/src/packaging/test/fixtures/resolve-alias/src/lib/sub/bar.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { baz } from '$lib/baz'; | ||
import { foo } from '$lib/sub/foo'; | ||
|
||
export const bar1 = foo; | ||
export const bar2 = baz; |
5 changes: 5 additions & 0 deletions
5
packages/kit/src/packaging/test/fixtures/resolve-alias/src/lib/sub/foo.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface Foo { | ||
foo: string; | ||
} | ||
|
||
export const foo: Foo = { foo: 'foo' }; |
5 changes: 5 additions & 0 deletions
5
packages/kit/src/packaging/test/fixtures/resolve-alias/svelte.config.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const preprocess = require('svelte-preprocess'); | ||
|
||
module.exports = { | ||
preprocess: preprocess() | ||
}; |
30 changes: 30 additions & 0 deletions
30
packages/kit/src/packaging/test/fixtures/resolve-alias/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"compilerOptions": { | ||
"moduleResolution": "node", | ||
"module": "es2020", | ||
"lib": ["es2020", "DOM"], | ||
"target": "es2019", | ||
/** | ||
svelte-preprocess cannot figure out whether you have a value or a type, so tell TypeScript | ||
to enforce using \`import type\` instead of \`import\` for Types. | ||
*/ | ||
"importsNotUsedAsValues": "error", | ||
"isolatedModules": true, | ||
"resolveJsonModule": true, | ||
/** | ||
To have warnings/errors of the Svelte compiler at the correct position, | ||
enable source maps by default. | ||
*/ | ||
"sourceMap": true, | ||
"esModuleInterop": true, | ||
"skipLibCheck": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"baseUrl": ".", | ||
"allowJs": true, | ||
"checkJs": true, | ||
"paths": { | ||
"$lib/*": ["src/lib/*"] | ||
} | ||
}, | ||
"include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.ts", "src/**/*.svelte"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters