Skip to content

Commit

Permalink
chore: add tsconfigPaths plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
sonofmagic committed Jul 9, 2024
1 parent 9d8969c commit 3b7d9be
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 40 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"scripts": {
"build": "pnpm run -r build",
"dev": "pnpm -r run dev",
"test": "vitest run --coverage.enabled",
"test:dev": "vitest --coverage.enabled",
"test": "vitest run",
"test:dev": "vitest",
"lint": "eslint packages/**/*.ts --fix",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"preinstall": "npx only-allow pnpm",
Expand Down Expand Up @@ -58,6 +58,7 @@
"unbuild": "^2.0.0",
"unplugin": "^1.11.0",
"unplugin-tailwindcss-mangle": "workspace:*",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^2.0.1"
}
}
21 changes: 12 additions & 9 deletions packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,8 @@
"utils"
],
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
".": "./src/index.ts"
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"typesVersions": {
"*": {
"*": [
Expand All @@ -47,7 +40,17 @@
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
"registry": "https://registry.npmjs.org/",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"dependencies": {
"@tailwindcss-mangle/shared": "workspace:^",
Expand Down
21 changes: 12 additions & 9 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,8 @@
"mangle"
],
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
".": "./src/index.ts"
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"typesVersions": {
"*": {
"*": [
Expand All @@ -48,7 +41,17 @@
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
"registry": "https://registry.npmjs.org/",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"dependencies": {
"@ast-core/escape": "^1.0.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/html/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Parser } from 'htmlparser2'
import MagicString from 'magic-string'
import { makeRegex, splitCode } from '@/shared'
import type { IHandlerTransformResult, IHtmlHandlerOptions } from '@/types'
import { makeRegex, splitCode } from '../shared'
import type { IHandlerTransformResult, IHtmlHandlerOptions } from '../types'

export function htmlHandler(raw: string | MagicString, options: IHtmlHandlerOptions): IHandlerTransformResult {
const { ctx, id } = options
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { StringLiteral, TemplateElement } from '@babel/types'
import MagicString from 'magic-string'
import { jsStringEscape } from '@ast-core/escape'
import { sort } from 'fast-sort'
import type { IHandlerTransformResult, IJsHandlerOptions } from '@/types'
import { makeRegex, splitCode } from '@/shared'
import { parse, traverse } from '@/babel'
import type { IHandlerTransformResult, IJsHandlerOptions } from '../types'
import { makeRegex, splitCode } from '../shared'
import { parse, traverse } from '../babel'

export function handleValue(raw: string, node: StringLiteral | TemplateElement, options: IJsHandlerOptions, ms: MagicString, offset: number, escape: boolean) {
const { ctx, splitQuote = true, id } = options
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"src",
"test"
]
}
}
21 changes: 12 additions & 9 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,8 @@
"utils"
],
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
".": "./src/index.ts"
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"typesVersions": {
"*": {
"*": [
Expand All @@ -46,7 +39,17 @@
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
"registry": "https://registry.npmjs.org/",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"dependencies": {},
"devDependencies": {}
Expand Down
2 changes: 2 additions & 0 deletions packages/unplugin-tailwindcss-mangle/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import path from 'node:path'
import { defineProject } from 'vitest/config'
import tsconfigPaths from 'vite-tsconfig-paths'

export default defineProject({
plugins: [tsconfigPaths()],
test: {
alias: [
{
Expand Down
29 changes: 29 additions & 0 deletions pnpm-lock.yaml

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

10 changes: 5 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Node",
"esModuleInterop": true,
"strict": true,
"moduleResolution": "Bundler",
"types": [
"vitest/globals"
]
],
"strict": true,
"esModuleInterop": true
}
}
}

0 comments on commit 3b7d9be

Please sign in to comment.