-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
102 additions
and
4 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 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Allow defining aliases with tsconfig |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { expect } from 'chai'; | ||
import * as cheerio from 'cheerio'; | ||
import { isWindows, loadFixture } from './test-utils.js'; | ||
|
||
describe('Aliases with tsconfig.json', () => { | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/alias-tsconfig/', | ||
}); | ||
}); | ||
|
||
if (isWindows) return; | ||
|
||
describe('dev', () => { | ||
let devServer; | ||
|
||
before(async () => { | ||
devServer = await fixture.startDevServer(); | ||
}); | ||
|
||
after(async () => { | ||
await devServer.stop(); | ||
}); | ||
|
||
it('can load client components', async () => { | ||
const html = await fixture.fetch('/').then((res) => res.text()); | ||
const $ = cheerio.load(html); | ||
|
||
// Should render aliased element | ||
expect($('#client').text()).to.equal('test'); | ||
|
||
const scripts = $('script').toArray(); | ||
expect(scripts.length).to.be.greaterThan(0); | ||
}); | ||
}); | ||
}); |
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,7 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import svelte from '@astrojs/svelte'; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
integrations: [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,9 @@ | ||
{ | ||
"name": "@test/aliases-tsconfig", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@astrojs/svelte": "workspace:*", | ||
"astro": "workspace:*" | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/astro/test/fixtures/alias-tsconfig/src/components/Client.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,2 @@ | ||
<script></script> | ||
<div id="client">test</div> |
15 changes: 15 additions & 0 deletions
15
packages/astro/test/fixtures/alias-tsconfig/src/pages/index.astro
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 Client from '@components/Client.svelte' | ||
--- | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<title>Aliases using tsconfig</title> | ||
</head> | ||
<body> | ||
<main> | ||
<Client client:load /> | ||
</main> | ||
</body> | ||
</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,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"paths": { | ||
"@components/*": [ | ||
"src/components/*" | ||
], | ||
"@layouts/*": [ | ||
"src/layouts/*" | ||
], | ||
"@assets/*": [ | ||
"src/assets/*" | ||
], | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.