Skip to content

Commit

Permalink
feat: 添加 transform 插件进行 d.ts alias 路径转换(Vue 尚不可用)
Browse files Browse the repository at this point in the history
  • Loading branch information
Liubasara committed Dec 27, 2021
1 parent fd2c56e commit dc83cb3
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 10 deletions.
10 changes: 4 additions & 6 deletions packages/@custom-ui/frame-select/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import FrameSelect from './main.vue'
// import FrameSelect from '@/main.vue'
import { useDemo } from '@/hooks/useDemo'

const a:number = 1
const a: number = 1

export {
a,
FrameSelect
}
export { a, FrameSelect, useDemo }

export default FrameSelect
export default FrameSelect
3 changes: 2 additions & 1 deletion packages/@custom-ui/frame-select/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"compilerOptions": {
"allowJs": true,
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"moduleResolution": "Node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
Expand Down
5 changes: 4 additions & 1 deletion packages/build-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
"rollup-plugin-postcss-webpack-alias-less-loader": "^1.0.0",
"rollup-plugin-typescript2": "^0.31.1",
"rollup-plugin-vue": "6.0.0",
"ts-node": "^10.4.0",
"tslib": "^2.3.1",
"typescript": "^4.5.2"
"ttypescript": "^1.5.13",
"typescript": "^4.5.2",
"typescript-transform-paths": "^3.3.1"
},
"publishConfig": {
"access": "public"
Expand Down
16 changes: 15 additions & 1 deletion packages/build-utils/src/custom-ui/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import parseArgs from 'minimist'
import lodashPkg from 'lodash'
import del from 'rollup-plugin-delete'
import alias from '@rollup/plugin-alias'
import ttypescript from 'ttypescript'

const { isArray, uniq } = lodashPkg

Expand Down Expand Up @@ -61,6 +62,7 @@ async function getPlugins(buildOpt) {
targets: path.resolve(buildOpt.componentPath, DIST, '*')
}),
alias({
resolve: ['.js', '.ts', '.vue'],
entries: [
{ find: '@', replacement: path.resolve(buildOpt.componentPath, 'src') }
]
Expand All @@ -71,7 +73,19 @@ async function getPlugins(buildOpt) {
tsconfig: tsConfigFilePath,
filterRoot: buildOpt.componentPath,
sourceMap: !IS_PRODUCTION,
inlineSources: !IS_PRODUCTION
inlineSources: !IS_PRODUCTION,
typescript: ttypescript,
tsconfigDefaults: {
compilerOptions: {
plugins: [
{ transform: 'typescript-transform-paths' },
{
transform: 'typescript-transform-paths',
afterDeclarations: true
}
]
}
}
}),
vuePlugin({
css: false
Expand Down
101 changes: 100 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,18 @@
exec-sh "^0.3.2"
minimist "^1.2.0"

"@cspotcode/[email protected]":
version "0.8.0"
resolved "https://registry.npmmirror.com/@cspotcode/source-map-consumer/download/@cspotcode/source-map-consumer-0.8.0.tgz#33bf4b7b39c178821606f669bbc447a6a629786b"
integrity sha1-M79LeznBeIIWBvZpu8RHpqYpeGs=

"@cspotcode/[email protected]":
version "0.7.0"
resolved "https://registry.npmmirror.com/@cspotcode/source-map-support/download/@cspotcode/source-map-support-0.7.0.tgz#4789840aa859e46d2f3173727ab707c66bf344f5"
integrity sha1-R4mECqhZ5G0vMXNyercHxmvzRPU=
dependencies:
"@cspotcode/source-map-consumer" "0.8.0"

"@discoveryjs/json-ext@^0.5.3":
version "0.5.6"
resolved "https://registry.npmmirror.com/@discoveryjs/json-ext/download/@discoveryjs/json-ext-0.5.6.tgz#d5e0706cf8c6acd8c6032f8d54070af261bbbb2f"
Expand Down Expand Up @@ -3315,6 +3327,26 @@
"@types/semver" "^7.3.9"
ts-type "^2.1.2"

"@tsconfig/node10@^1.0.7":
version "1.0.8"
resolved "https://registry.npmmirror.com/@tsconfig/node10/download/@tsconfig/node10-1.0.8.tgz#c1e4e80d6f964fbecb3359c43bd48b40f7cadad9"
integrity sha1-weToDW+WT77LM1nEO9SLQPfK2tk=

"@tsconfig/node12@^1.0.7":
version "1.0.9"
resolved "https://registry.npmmirror.com/@tsconfig/node12/download/@tsconfig/node12-1.0.9.tgz#62c1f6dee2ebd9aead80dc3afa56810e58e1a04c"
integrity sha1-YsH23uLr2a6tgNw6+laBDljhoEw=

"@tsconfig/node14@^1.0.0":
version "1.0.1"
resolved "https://registry.npmmirror.com/@tsconfig/node14/download/@tsconfig/node14-1.0.1.tgz#95f2d167ffb9b8d2068b0b235302fafd4df711f2"
integrity sha1-lfLRZ/+5uNIGiwsjUwL6/U33EfI=

"@tsconfig/node16@^1.0.2":
version "1.0.2"
resolved "https://registry.npmmirror.com/@tsconfig/node16/download/@tsconfig/node16-1.0.2.tgz#423c77877d0569db20e1fc80885ac4118314010e"
integrity sha1-Qjx3h30Fadsg4fyAiFrEEYMUAQ4=

"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.14":
version "7.1.16"
resolved "https://registry.npmmirror.com/@types/babel__core/download/@types/babel__core-7.1.16.tgz#bc12c74b7d65e82d29876b5d0baf5c625ac58702"
Expand Down Expand Up @@ -3956,6 +3988,11 @@ acorn-walk@^7.1.1, acorn-walk@^7.2.0:
resolved "https://registry.nlark.com/acorn-walk/download/acorn-walk-7.2.0.tgz?cache=0&sync_timestamp=1630916608758&other_urls=https%3A%2F%2Fregistry.nlark.com%2Facorn-walk%2Fdownload%2Facorn-walk-7.2.0.tgz#0de889a601203909b0fbe07b8938dc21d2e967bc"
integrity sha1-DeiJpgEgOQmw++B7iTjcIdLpZ7w=

acorn-walk@^8.1.1:
version "8.2.0"
resolved "https://registry.npmmirror.com/acorn-walk/download/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1"
integrity sha1-dBIQ8uJCZFRQiFOi9E0KuDt/acE=

acorn@^6.4.1:
version "6.4.2"
resolved "https://registry.npmmirror.com/acorn/download/acorn-6.4.2.tgz?cache=0&sync_timestamp=1637225492710&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Facorn%2Fdownload%2Facorn-6.4.2.tgz#35866fd710528e92de10cf06016498e47e39e1e6"
Expand All @@ -3971,6 +4008,11 @@ acorn@^8.2.4:
resolved "https://registry.npmmirror.com/acorn/download/acorn-8.6.0.tgz?cache=0&sync_timestamp=1637225522161&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Facorn%2Fdownload%2Facorn-8.6.0.tgz#e3692ba0eb1a0c83eaa4f37f5fa7368dd7142895"
integrity sha512-U1riIR+lBSNi3IbxtaHOIKdH8sLFv3NYfNv8sg7ZsNhcfl4HF2++BfqqrNAxoCLQW1iiylOj76ecnaUxz+z9yw==

acorn@^8.4.1:
version "8.7.0"
resolved "https://registry.npmmirror.com/acorn/download/acorn-8.7.0.tgz#90951fde0f8f09df93549481e5fc141445b791cf"
integrity sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==

add-stream@^1.0.0:
version "1.0.0"
resolved "https://registry.nlark.com/add-stream/download/add-stream-1.0.0.tgz#6a7990437ca736d5e1288db92bd3266d5f5cb2aa"
Expand Down Expand Up @@ -4175,6 +4217,11 @@ are-we-there-yet@~1.1.2:
delegates "^1.0.0"
readable-stream "^2.0.6"

arg@^4.1.0:
version "4.1.3"
resolved "https://registry.npmmirror.com/arg/download/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089"
integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==

argparse@^1.0.7:
version "1.0.10"
resolved "https://registry.nlark.com/argparse/download/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
Expand Down Expand Up @@ -5792,6 +5839,11 @@ create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7:
safe-buffer "^5.0.1"
sha.js "^2.4.8"

create-require@^1.1.0:
version "1.1.1"
resolved "https://registry.npmmirror.com/create-require/download/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333"
integrity sha1-wdfo8eX2z8n/ZfnNNS03NIdWwzM=

[email protected], cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.nlark.com/cross-spawn/download/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
Expand Down Expand Up @@ -6224,6 +6276,11 @@ diff-sequences@^27.4.0:
resolved "https://registry.npmmirror.com/diff-sequences/download/diff-sequences-27.4.0.tgz#d783920ad8d06ec718a060d00196dfef25b132a5"
integrity sha512-YqiQzkrsmHMH5uuh8OdQFU9/ZpADnwzml8z0O5HvRNda+5UZsaX/xN+AAxfR2hWq1Y7HZnAzO9J5lJXOuDz2Ww==

diff@^4.0.1:
version "4.0.2"
resolved "https://registry.npmmirror.com/diff/download/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d"
integrity sha1-YPOuy4nV+uUgwRqhnvwruYKq3n0=

diffie-hellman@^5.0.0:
version "5.0.3"
resolved "https://registry.npmmirror.com/diffie-hellman/download/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875"
Expand Down Expand Up @@ -9811,6 +9868,11 @@ make-dir@^3.0.0, make-dir@^3.0.2, make-dir@^3.1.0:
dependencies:
semver "^6.0.0"

make-error@^1.1.1:
version "1.3.6"
resolved "https://registry.npmmirror.com/make-error/download/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2"
integrity sha1-LrLjfqm2fEiR9oShOUeZr0hM96I=

make-fetch-happen@^8.0.9:
version "8.0.14"
resolved "https://registry.nlark.com/make-fetch-happen/download/make-fetch-happen-8.0.14.tgz?cache=0&sync_timestamp=1629820656927&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fmake-fetch-happen%2Fdownload%2Fmake-fetch-happen-8.0.14.tgz#aaba73ae0ab5586ad8eaa68bd83332669393e222"
Expand Down Expand Up @@ -12774,7 +12836,7 @@ resolve.exports@^1.1.0:
resolved "https://registry.npmmirror.com/resolve.exports/download/resolve.exports-1.1.0.tgz#5ce842b94b05146c0e03076985d1d0e7e48c90c9"
integrity sha1-XOhCuUsFFGwOAwdphdHQ5+SMkMk=

[email protected], resolve@^1.1.6, resolve@^1.10.0, resolve@^1.12.0, resolve@^1.14.2, resolve@^1.15.1, resolve@^1.19.0, resolve@^1.20.0, resolve@^1.3.2:
[email protected], resolve@>=1.9.0, resolve@^1.1.6, resolve@^1.10.0, resolve@^1.12.0, resolve@^1.14.2, resolve@^1.15.1, resolve@^1.19.0, resolve@^1.20.0, resolve@^1.3.2:
version "1.20.0"
resolved "https://registry.npm.taobao.org/resolve/download/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975"
integrity sha1-YpoBP7P3B1XW8LeTXMHCxTeLGXU=
Expand Down Expand Up @@ -14152,6 +14214,24 @@ ts-map@^1.0.3:
resolved "https://registry.npmmirror.com/ts-map/download/ts-map-1.0.3.tgz#1c4d218dec813d2103b7e04e4bcf348e1471c1ff"
integrity sha1-HE0hjeyBPSEDt+BOS880jhRxwf8=

ts-node@^10.4.0:
version "10.4.0"
resolved "https://registry.npmmirror.com/ts-node/download/ts-node-10.4.0.tgz#680f88945885f4e6cf450e7f0d6223dd404895f7"
integrity sha1-aA+IlFiF9ObPRQ5/DWIj3UBIlfc=
dependencies:
"@cspotcode/source-map-support" "0.7.0"
"@tsconfig/node10" "^1.0.7"
"@tsconfig/node12" "^1.0.7"
"@tsconfig/node14" "^1.0.0"
"@tsconfig/node16" "^1.0.2"
acorn "^8.4.1"
acorn-walk "^8.1.1"
arg "^4.1.0"
create-require "^1.1.0"
diff "^4.0.1"
make-error "^1.1.1"
yn "3.1.1"

ts-pnp@^1.1.6:
version "1.2.0"
resolved "https://registry.npmmirror.com/ts-pnp/download/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92"
Expand Down Expand Up @@ -14185,6 +14265,13 @@ [email protected]:
resolved "https://registry.npmmirror.com/tty-browserify/download/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6"
integrity sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=

ttypescript@^1.5.13:
version "1.5.13"
resolved "https://registry.npmmirror.com/ttypescript/download/ttypescript-1.5.13.tgz#c3bcb760599fe49157d30c5d5895a0023cbb7f30"
integrity sha512-KT/RBfGGlVJFqEI8cVvI3nMsmYcFvPSZh8bU0qX+pAwbi7/ABmYkzn7l/K8skw0xmYjVCoyaV6WLsBQxdadybQ==
dependencies:
resolve ">=1.9.0"

tunnel-agent@^0.6.0:
version "0.6.0"
resolved "https://registry.nlark.com/tunnel-agent/download/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd"
Expand Down Expand Up @@ -14264,6 +14351,13 @@ typedarray@^0.0.6:
resolved "https://registry.nlark.com/typedarray/download/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=

typescript-transform-paths@^3.3.1:
version "3.3.1"
resolved "https://registry.npmmirror.com/typescript-transform-paths/download/typescript-transform-paths-3.3.1.tgz#74526bc1b6dc575ffe269cc81833db7bd81763e1"
integrity sha1-dFJrwbbcV1/+JpzIGDPbe9gXY+E=
dependencies:
minimatch "^3.0.4"

[email protected], typescript@^4.5.2:
version "4.5.2"
resolved "https://registry.npmmirror.com/typescript/download/typescript-4.5.2.tgz#8ac1fba9f52256fdb06fb89e4122fa6a346c2998"
Expand Down Expand Up @@ -15163,6 +15257,11 @@ yauzl@^2.10.0:
buffer-crc32 "~0.2.3"
fd-slicer "~1.1.0"

[email protected]:
version "3.1.1"
resolved "https://registry.npmmirror.com/yn/download/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50"
integrity sha1-HodAGgnXZ8HV6rJqbkwYUYLS61A=

yocto-queue@^0.1.0:
version "0.1.0"
resolved "https://registry.nlark.com/yocto-queue/download/yocto-queue-0.1.0.tgz?cache=0&sync_timestamp=1628813299341&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fyocto-queue%2Fdownload%2Fyocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
Expand Down

0 comments on commit dc83cb3

Please sign in to comment.