Skip to content

feat: deprecate @ alias in favor of the imports field in package.json #412

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: use package.json imports instead of @ as alias to src
  • Loading branch information
haoqunjiang committed Dec 26, 2023
commit 46791d715e53f7e442e0c34f5e922d63dbe77f9a
3 changes: 3 additions & 0 deletions template/base/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"compilerOptions": {
"paths": {
// TODO: no longer needed after TS 5.4
"#src/*": ["./src/*"],
// Deprecated, use `#src` instead (configured in `package.json` `imports` field)
"@/*": ["./src/*"]
}
},
3 changes: 3 additions & 0 deletions template/base/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"private": true,
"type": "module",
"imports": {
"#src/": "./src/"
},
"scripts": {
"dev": "vite",
"build": "vite build",
1 change: 1 addition & 0 deletions template/base/vite.config.js.ejs
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ export default defineConfig({
],
resolve: {
alias: {
// Deprecated, use `#src` instead (configured in `package.json` `imports` field)
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
2 changes: 1 addition & 1 deletion template/code/router/src/App.vue
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import HelloWorld from './components/HelloWorld.vue'

<template>
<header>
<img alt="Vue logo" class="logo" src="@/assets/logo.svg" width="125" height="125" />
<img alt="Vue logo" class="logo" src="#src/assets/logo.svg" width="125" height="125" />

<div class="wrapper">
<HelloWorld msg="You did it!" />
2 changes: 1 addition & 1 deletion template/code/typescript-router/src/App.vue
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import HelloWorld from './components/HelloWorld.vue'

<template>
<header>
<img alt="Vue logo" class="logo" src="@/assets/logo.svg" width="125" height="125" />
<img alt="Vue logo" class="logo" src="#src/assets/logo.svg" width="125" height="125" />

<div class="wrapper">
<HelloWorld msg="You did it!" />
2 changes: 1 addition & 1 deletion template/config/cypress-ct/cypress/support/component.js
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ import './commands'
// require('./commands')

// Import global styles
import '@/assets/main.css'
import '#src/assets/main.css'

import { mount } from 'cypress/vue'

2 changes: 1 addition & 1 deletion template/config/cypress-ct/cypress/support/component.ts
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ import './commands'
// require('./commands')

// Import global styles
import '@/assets/main.css'
import '#src/assets/main.css'

import { mount } from 'cypress/vue'

3 changes: 3 additions & 0 deletions template/tsconfig/base/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -8,6 +8,9 @@

"baseUrl": ".",
"paths": {
// TODO: no longer needed after TS 5.4
"#src/*": ["./src/*"],
// Deprecated, use `#src` instead (configured in `package.json` `imports` field)
"@/*": ["./src/*"]
}
}
3 changes: 3 additions & 0 deletions template/tsconfig/nightwatch-ct/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -8,6 +8,9 @@

"baseUrl": ".",
"paths": {
// TODO: no longer needed after TS 5.4
"#src/*": ["./src/*"],
// Deprecated, use `#src` instead (configured in `package.json` `imports` field)
"@/*": ["./src/*"]
}
}