Skip to content

Commit 46791d7

Browse files
committed
feat: use package.json imports instead of @ as alias to src
See reasons at https://github.com/epicweb-dev/epic-stack/blob/main/docs/decisions/031-imports.md and vuejs/core#9919 Pending vuejs/core#9919 to be fixed Pending microsoft/TypeScript#55015 to be released
1 parent b1505e4 commit 46791d7

File tree

9 files changed

+17
-4
lines changed

9 files changed

+17
-4
lines changed

Diff for: template/base/jsconfig.json

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"compilerOptions": {
33
"paths": {
4+
// TODO: no longer needed after TS 5.4
5+
"#src/*": ["./src/*"],
6+
// Deprecated, use `#src` instead (configured in `package.json` `imports` field)
47
"@/*": ["./src/*"]
58
}
69
},

Diff for: template/base/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"private": true,
33
"type": "module",
4+
"imports": {
5+
"#src/": "./src/"
6+
},
47
"scripts": {
58
"dev": "vite",
69
"build": "vite build",

Diff for: template/base/vite.config.js.ejs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default defineConfig({
1414
],
1515
resolve: {
1616
alias: {
17+
// Deprecated, use `#src` instead (configured in `package.json` `imports` field)
1718
'@': fileURLToPath(new URL('./src', import.meta.url))
1819
}
1920
}

Diff for: template/code/router/src/App.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import HelloWorld from './components/HelloWorld.vue'
55

66
<template>
77
<header>
8-
<img alt="Vue logo" class="logo" src="@/assets/logo.svg" width="125" height="125" />
8+
<img alt="Vue logo" class="logo" src="#src/assets/logo.svg" width="125" height="125" />
99

1010
<div class="wrapper">
1111
<HelloWorld msg="You did it!" />

Diff for: template/code/typescript-router/src/App.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import HelloWorld from './components/HelloWorld.vue'
55

66
<template>
77
<header>
8-
<img alt="Vue logo" class="logo" src="@/assets/logo.svg" width="125" height="125" />
8+
<img alt="Vue logo" class="logo" src="#src/assets/logo.svg" width="125" height="125" />
99

1010
<div class="wrapper">
1111
<HelloWorld msg="You did it!" />

Diff for: template/config/cypress-ct/cypress/support/component.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import './commands'
2020
// require('./commands')
2121

2222
// Import global styles
23-
import '@/assets/main.css'
23+
import '#src/assets/main.css'
2424

2525
import { mount } from 'cypress/vue'
2626

Diff for: template/config/cypress-ct/cypress/support/component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import './commands'
2020
// require('./commands')
2121

2222
// Import global styles
23-
import '@/assets/main.css'
23+
import '#src/assets/main.css'
2424

2525
import { mount } from 'cypress/vue'
2626

Diff for: template/tsconfig/base/tsconfig.app.json

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
"baseUrl": ".",
1010
"paths": {
11+
// TODO: no longer needed after TS 5.4
12+
"#src/*": ["./src/*"],
13+
// Deprecated, use `#src` instead (configured in `package.json` `imports` field)
1114
"@/*": ["./src/*"]
1215
}
1316
}

Diff for: template/tsconfig/nightwatch-ct/tsconfig.app.json

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
"baseUrl": ".",
1010
"paths": {
11+
// TODO: no longer needed after TS 5.4
12+
"#src/*": ["./src/*"],
13+
// Deprecated, use `#src` instead (configured in `package.json` `imports` field)
1114
"@/*": ["./src/*"]
1215
}
1316
}

0 commit comments

Comments
 (0)