summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/astro/test/alias-tsconfig.test.js24
-rw-r--r--packages/astro/test/fixtures/alias-tsconfig/deps/namespace-package/index.js1
-rw-r--r--packages/astro/test/fixtures/alias-tsconfig/deps/namespace-package/package.json7
-rw-r--r--packages/astro/test/fixtures/alias-tsconfig/package.json1
-rw-r--r--packages/astro/test/fixtures/alias-tsconfig/src/components/Foo.astro1
-rw-r--r--packages/astro/test/fixtures/alias-tsconfig/src/components/Style.astro2
-rw-r--r--packages/astro/test/fixtures/alias-tsconfig/src/pages/index.astro10
-rw-r--r--packages/astro/test/fixtures/alias-tsconfig/src/styles/extra.css3
-rw-r--r--packages/astro/test/fixtures/alias-tsconfig/src/styles/main.css5
-rw-r--r--packages/astro/test/fixtures/alias-tsconfig/src/utils/constants.js1
-rw-r--r--packages/astro/test/fixtures/alias-tsconfig/tsconfig.json11
-rw-r--r--pnpm-lock.yaml5
12 files changed, 66 insertions, 5 deletions
diff --git a/packages/astro/test/alias-tsconfig.test.js b/packages/astro/test/alias-tsconfig.test.js
index 1468aabeb..07dd1fe23 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 000000000..fd728a832
--- /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 000000000..90136cfda
--- /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 61e7fb4cb..dc4b7e7b9 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 000000000..42bd5c2a5
--- /dev/null
+++ b/packages/astro/test/fixtures/alias-tsconfig/src/components/Foo.astro
@@ -0,0 +1 @@
+<p id="foo">foo</p> \ 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 000000000..9468ef80e
--- /dev/null
+++ b/packages/astro/test/fixtures/alias-tsconfig/src/components/Style.astro
@@ -0,0 +1,2 @@
+<p id="style-blue">i am blue</p>
+<p id="style-red">i am red</p> \ 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 c00b9f083..00dc44b92 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';
---
<html lang="en">
<head>
@@ -10,6 +16,10 @@ import Client from '@components/Client.svelte'
<body>
<main>
<Client client:load />
+ <Foo />
+ <StyleComp />
+ <p id="namespace">{namespace}</p>
+ <p id="constants-foo">{foo}</p>
</main>
</body>
</html>
diff --git a/packages/astro/test/fixtures/alias-tsconfig/src/styles/extra.css b/packages/astro/test/fixtures/alias-tsconfig/src/styles/extra.css
new file mode 100644
index 000000000..0b41276e8
--- /dev/null
+++ b/packages/astro/test/fixtures/alias-tsconfig/src/styles/extra.css
@@ -0,0 +1,3 @@
+#style-red {
+ color: red;
+} \ No newline at end of file
diff --git a/packages/astro/test/fixtures/alias-tsconfig/src/styles/main.css b/packages/astro/test/fixtures/alias-tsconfig/src/styles/main.css
new file mode 100644
index 000000000..9fd83beee
--- /dev/null
+++ b/packages/astro/test/fixtures/alias-tsconfig/src/styles/main.css
@@ -0,0 +1,5 @@
+@import "@styles/extra.css";
+
+#style-blue {
+ color: blue;
+} \ No newline at end of file
diff --git a/packages/astro/test/fixtures/alias-tsconfig/src/utils/constants.js b/packages/astro/test/fixtures/alias-tsconfig/src/utils/constants.js
new file mode 100644
index 000000000..cb3564682
--- /dev/null
+++ b/packages/astro/test/fixtures/alias-tsconfig/src/utils/constants.js
@@ -0,0 +1 @@
+export const foo = 'foo'
diff --git a/packages/astro/test/fixtures/alias-tsconfig/tsconfig.json b/packages/astro/test/fixtures/alias-tsconfig/tsconfig.json
index 01dd88abe..52553e7d3 100644
--- a/packages/astro/test/fixtures/alias-tsconfig/tsconfig.json
+++ b/packages/astro/test/fixtures/alias-tsconfig/tsconfig.json
@@ -5,12 +5,13 @@
"@components/*": [
"src/components/*"
],
- "@layouts/*": [
- "src/layouts/*"
- ],
- "@assets/*": [
- "src/assets/*"
+ "@styles/*": [
+ "src/styles/*"
],
+ // this can really trip up namespaced packages
+ "@*": [
+ "src/*"
+ ]
}
}
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 556de504f..5789d3ae1 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1270,13 +1270,18 @@ importers:
packages/astro/test/fixtures/alias-tsconfig:
specifiers:
'@astrojs/svelte': workspace:*
+ '@test/namespace-package': workspace:*
astro: workspace:*
svelte: ^3.48.0
dependencies:
'@astrojs/svelte': link:../../../../integrations/svelte
+ '@test/namespace-package': link:deps/namespace-package
astro: link:../../..
svelte: 3.55.1
+ packages/astro/test/fixtures/alias-tsconfig/deps/namespace-package:
+ specifiers: {}
+
packages/astro/test/fixtures/api-routes:
specifiers:
astro: workspace:*