{namespace}
+{foo}
diff --git a/packages/astro/test/alias-tsconfig.test.js b/packages/astro/test/alias-tsconfig.test.js index 1468aabeb5..07dd1fe239 100644 --- a/packages/astro/test/alias-tsconfig.test.js +++ b/packages/astro/test/alias-tsconfig.test.js @@ -34,5 +34,29 @@ describe('Aliases with tsconfig.json', () => { const scripts = $('script').toArray(); expect(scripts.length).to.be.greaterThan(0); }); + + it('can load via baseUrl', async () => { + const html = await fixture.fetch('/').then((res) => res.text()); + const $ = cheerio.load(html); + + expect($('#foo').text()).to.equal('foo'); + expect($('#constants-foo').text()).to.equal('foo'); + }); + + it('can load namespace packages with @* paths', async () => { + const html = await fixture.fetch('/').then((res) => res.text()); + const $ = cheerio.load(html); + + expect($('#namespace').text()).to.equal('namespace'); + }); + + // TODO: fix this https://github.com/withastro/astro/issues/6551 + it.skip('works in css @import', async () => { + const html = await fixture.fetch('/').then((res) => res.text()); + console.log(html); + // imported css should be bundled + expect(html).to.include('#style-red'); + expect(html).to.include('#style-blue'); + }); }); }); diff --git a/packages/astro/test/fixtures/alias-tsconfig/deps/namespace-package/index.js b/packages/astro/test/fixtures/alias-tsconfig/deps/namespace-package/index.js new file mode 100644 index 0000000000..fd728a8325 --- /dev/null +++ b/packages/astro/test/fixtures/alias-tsconfig/deps/namespace-package/index.js @@ -0,0 +1 @@ +export const namespace = 'namespace'; \ No newline at end of file diff --git a/packages/astro/test/fixtures/alias-tsconfig/deps/namespace-package/package.json b/packages/astro/test/fixtures/alias-tsconfig/deps/namespace-package/package.json new file mode 100644 index 0000000000..90136cfda7 --- /dev/null +++ b/packages/astro/test/fixtures/alias-tsconfig/deps/namespace-package/package.json @@ -0,0 +1,7 @@ +{ + "name": "@test/namespace-package", + "version": "0.0.0", + "private": true, + "type": "module", + "exports": "./index.js" +} diff --git a/packages/astro/test/fixtures/alias-tsconfig/package.json b/packages/astro/test/fixtures/alias-tsconfig/package.json index 61e7fb4cb5..dc4b7e7b9e 100644 --- a/packages/astro/test/fixtures/alias-tsconfig/package.json +++ b/packages/astro/test/fixtures/alias-tsconfig/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "@astrojs/svelte": "workspace:*", + "@test/namespace-package": "workspace:*", "astro": "workspace:*", "svelte": "^3.48.0" } diff --git a/packages/astro/test/fixtures/alias-tsconfig/src/components/Foo.astro b/packages/astro/test/fixtures/alias-tsconfig/src/components/Foo.astro new file mode 100644 index 0000000000..42bd5c2a53 --- /dev/null +++ b/packages/astro/test/fixtures/alias-tsconfig/src/components/Foo.astro @@ -0,0 +1 @@ +
foo
\ No newline at end of file diff --git a/packages/astro/test/fixtures/alias-tsconfig/src/components/Style.astro b/packages/astro/test/fixtures/alias-tsconfig/src/components/Style.astro new file mode 100644 index 0000000000..9468ef80e3 --- /dev/null +++ b/packages/astro/test/fixtures/alias-tsconfig/src/components/Style.astro @@ -0,0 +1,2 @@ +i am blue
+i am red
\ No newline at end of file diff --git a/packages/astro/test/fixtures/alias-tsconfig/src/pages/index.astro b/packages/astro/test/fixtures/alias-tsconfig/src/pages/index.astro index c00b9f0836..00dc44b92c 100644 --- a/packages/astro/test/fixtures/alias-tsconfig/src/pages/index.astro +++ b/packages/astro/test/fixtures/alias-tsconfig/src/pages/index.astro @@ -1,5 +1,11 @@ --- import Client from '@components/Client.svelte' +import Foo from 'src/components/Foo.astro'; +import StyleComp from 'src/components/Style.astro'; +import { namespace } from '@test/namespace-package' +import { foo } from 'src/utils/constants'; +// TODO: support alias in @import https://github.com/withastro/astro/issues/6551 +// import '@styles/main.css'; --- @@ -10,6 +16,10 @@ import Client from '@components/Client.svelte'{namespace}
+{foo}