Skip to content

Commit

Permalink
🐛 alias in types (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
JiangWeixian authored May 8, 2022
1 parent 8197035 commit 7df83ac
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 35 deletions.
5 changes: 5 additions & 0 deletions .changeset/nasty-ladybugs-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@aiou/rollup-template": patch
---

fix alias in emit types
33 changes: 18 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,30 @@
"functional-md": "^1.1.0"
},
"devDependencies": {
"@aiou/eslint-config": "^0.5.1",
"@changesets/cli": "^2.21.1",
"@rollup/plugin-alias": "^3.1.9",
"@rollup/plugin-commonjs": "^21.0.2",
"@rollup/plugin-node-resolve": "^13.1.3",
"@types/node": "^17.0.22",
"cz-emoji": "^1.3.1",
"eslint": "^8.11.0",
"esrua": "^0.2.1",
"husky": "^7.0.4",
"lint-staged": "^11.2.6",
"@aiou/eslint-config": "0.5.1",
"@changesets/cli": "2.21.1",
"@rollup/plugin-alias": "3.1.9",
"@rollup/plugin-commonjs": "21.0.2",
"@rollup/plugin-node-resolve": "13.1.3",
"@types/node": "17.0.22",
"cz-emoji": "1.3.1",
"eslint": "8.11.0",
"esrua": "0.2.1",
"husky": "7.0.4",
"lint-staged": "11.2.6",
"prettier": "2.4.1",
"rimraf": "3.0.2",
"rollup": "2.71.1",
"rollup-plugin-condition-exports": "^1.3.1",
"rollup-plugin-filesize": "^9.1.2",
"rollup-plugin-node-externals": "^4.0.0",
"rollup-plugin-condition-exports": "1.3.1",
"rollup-plugin-filesize": "9.1.2",
"rollup-plugin-node-externals": "4.0.0",
"rollup-plugin-typescript2": "0.31.2",
"ts-node": "^10.7.0",
"tslib": "2.4.0",
"ttypescript": "1.5.13",
"typescript": "4.4.3",
"vitest": "^0.10.0"
"typescript-transform-paths": "3.3.1",
"vitest": "0.10.0"
},
"config": {
"commitizen": {
Expand Down
147 changes: 132 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ export default defineConfig([
devDeps: false,
}),
commonjs(),
typescript(),
typescript({
// rollup-plugin-typescript2 can not process alias on emit types
// require ttypescript tranform alias
typescript: require('ttypescript'),
}),
alias({
resolve: ['.ts', '.js', '.tsx', '.jsx'],
entries: [{ find: '@/', replacement: './src/' }],
Expand Down
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Table } from './md'
import { Table } from '@/md'

Table()
export const display = (): ReturnType<typeof Table> => {
return Table()
}

export const welcome = () => {
console.log('hello world')
Expand Down
11 changes: 9 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
},
"plugins": [
{ "transform": "typescript-transform-paths" },
{
"transform": "typescript-transform-paths",
"afterDeclarations": true
}
]
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
"exclude": ["dist"]
}
10 changes: 10 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import path from 'path'
import { defineConfig } from 'vitest/config'

export default defineConfig({
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
})

0 comments on commit 7df83ac

Please sign in to comment.