-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] support for other aliases in package command #6350
Merged
dummdidumm
merged 5 commits into
sveltejs:master
from
BeeMargarida:package/support-aliases
Aug 29, 2022
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
464f6d8
support aliases in package command
BeeMargarida 228f611
test for resolve alias support for other aliases
BeeMargarida 7212726
move alias replace loop inside import path replace
BeeMargarida 6ad644c
added changeset
BeeMargarida 578b6c8
Update .changeset/weak-hotels-hang.md
dummdidumm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
2 changes: 2 additions & 0 deletions
2
packages/package/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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<script> | ||
import { foo } from './sub/foo'; | ||
import { util } from './utils'; | ||
export let bar = foo; | ||
util(); | ||
</script> |
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
1 change: 1 addition & 0 deletions
1
packages/package/test/fixtures/resolve-alias/expected/utils/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 declare const util: () => void; |
1 change: 1 addition & 0 deletions
1
packages/package/test/fixtures/resolve-alias/expected/utils/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 const util = () => { }; |
3 changes: 3 additions & 0 deletions
3
packages/package/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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
<script lang="ts"> | ||
import { foo } from '$lib/sub/foo'; | ||
import { util } from '$utils'; | ||
|
||
export let bar = foo; | ||
|
||
util(); | ||
</script> |
1 change: 1 addition & 0 deletions
1
packages/package/test/fixtures/resolve-alias/src/lib/utils/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 const util = () => {}; |
12 changes: 11 additions & 1 deletion
12
packages/package/test/fixtures/resolve-alias/svelte.config.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 |
---|---|---|
@@ -1,5 +1,15 @@ | ||
import preprocess from 'svelte-preprocess'; | ||
import { fileURLToPath } from 'url'; | ||
import path from 'path'; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.join(__filename, '..'); | ||
|
||
export default { | ||
preprocess: preprocess() | ||
preprocess: preprocess(), | ||
kit: { | ||
alias: { | ||
$utils: path.resolve(__dirname, './src/lib/utils') | ||
} | ||
} | ||
}; |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is propbably super edge-case-y, but this could theoretically replace import paths multiple times. Could we turn that around and do the for loop inside the replace functions, and check if a replacement was done by checking if output != match?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, there was that possibility. I moved the loop inside, but I did not understood what you meant by the last part of checking if output != match.