Skip to content

Commit

Permalink
use subpath imports instead of tsc path alias
Browse files Browse the repository at this point in the history
  • Loading branch information
yo-iwamoto committed Sep 21, 2024
1 parent c8456f7 commit 739c38e
Show file tree
Hide file tree
Showing 20 changed files with 40 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "@/styles/global.scss";
import "#src/styles/global.scss";
import type { Preview } from "@storybook/react";

const preview: Preview = {
Expand Down
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
"source.fixAll.eslint": "explicit"
},
"eslint.validate": ["typescript", "typescriptreact"],
"typescript.tsdk": "node_modules/.pnpm/[email protected]/node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
"biome.enabled": true
}
4 changes: 2 additions & 2 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"cssVariables": true
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
"components": "#src/components",
"utils": "#src/lib/utils"
}
}
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "blog.yoiw.dev",
"license": "MIT",
"packageManager": "pnpm@8.15.6",
"packageManager": "pnpm@9.11.0",
"scripts": {
"prepare": "git config core.hooksPath .githooks",
"dev": "pnpm run '/^dev:.*/'",
Expand All @@ -22,6 +22,9 @@
"build-storybook": "storybook build",
"chromatic": "chromatic"
},
"imports": {
"#*": ["./*", "./*.ts", "./*.tsx", "./*/index.ts", "./*/index.tsx"]
},
"dependencies": {
"@radix-ui/react-slot": "1.1.0",
"class-variance-authority": "0.7.0",
Expand Down Expand Up @@ -73,6 +76,5 @@
"unified": "11.0.5",
"vite-plugin-environment": "1.1.3",
"vitest": "2.1.1"
},
"version": ""
}
}
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

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

6 changes: 3 additions & 3 deletions src/app/_internal/post-card-list/post-card-list.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Link } from "@/components/link";
import { Text } from "@/components/text";
import { cn } from "@/lib/utils";
import { Link } from "#src/components/link";
import { Text } from "#src/components/text/text.jsx";
import { cn } from "#src/lib/utils";
import type { PropsWithChildren } from "react";

function PostCardListRoot({ children }: PropsWithChildren) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/_internal/root-layout/nav-link.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { cn } from "@/lib/utils";
import { cn } from "#src/lib/utils";
import Link from "next/link";
import { usePathname } from "next/navigation";
import type { PropsWithChildren } from "react";
Expand Down
4 changes: 2 additions & 2 deletions src/app/_internal/root-layout/root-layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Link } from "@/components/link";
import { SizedBox } from "@/components/sized-box";
import { Link } from "#src/components/link";
import { SizedBox } from "#src/components/sized-box";
import type { PropsWithChildren } from "react";
import { NavLink } from "./nav-link";

Expand Down
4 changes: 2 additions & 2 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getServerSideEnv } from "@/config/env";
import "@/styles/global.scss";
import { getServerSideEnv } from "#src/config/env";
import "#src/styles/global.scss";
import type { Metadata } from "next";
import type { PropsWithChildren } from "react";
import { RootLayout } from "./_internal/root-layout";
Expand Down
4 changes: 2 additions & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Text } from "@/components/text";
import { allEntries } from "@/data/contents";
import { Text } from "#src/components/text";
import { allEntries } from "../data/contents";
import { PostCardList } from "./_internal/post-card-list";

export const dynamic = "force-static";
Expand Down
4 changes: 2 additions & 2 deletions src/app/posts/[slug]/generate-metadata.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { allEntries } from "@/data/contents";
import { extractTextFromArticleHtml } from "@/lib/extract-text-from-article-html";
import { allEntries } from "#src/data/contents";
import { extractTextFromArticleHtml } from "#src/lib/extract-text-from-article-html";
import type { Metadata } from "next";
import { notFound } from "next/navigation";

Expand Down
2 changes: 1 addition & 1 deletion src/app/posts/[slug]/generate-static-params.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { allEntries } from "@/data/contents";
import { allEntries } from "#src/data/contents";

export function generateStaticParams() {
const articles = allEntries;
Expand Down
8 changes: 4 additions & 4 deletions src/app/posts/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Link } from "@/components/link";
import { Text } from "@/components/text";
import { allEntries } from "@/data/contents";
import "@/styles/post-body.scss";
import { Link } from "#src/components/link";
import { Text } from "#src/components/text";
import { allEntries } from "#src/data/contents";
import "#src/styles/post-body.scss";
import { notFound } from "next/navigation";
import HighlightNode from "./_internal/highlight-node-internal";

Expand Down
2 changes: 1 addition & 1 deletion src/app/tags/[slug]/generate-static-params.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { allEntries } from "@/data/contents";
import { allEntries } from "#src/data/contents";

export function generateStaticParams() {
const tags = new Set();
Expand Down
6 changes: 3 additions & 3 deletions src/app/tags/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PostCardList } from "@/app/_internal/post-card-list";
import { Text } from "@/components/text";
import { allEntries } from "@/data/contents";
import { PostCardList } from "#src/app/_internal/post-card-list";
import { Text } from "#src/components/text";
import { allEntries } from "#src/data/contents";
import { notFound } from "next/navigation";

export { generateMetadata } from "./generate-metadata";
Expand Down
6 changes: 3 additions & 3 deletions src/app/tags/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Link } from "@/components/link";
import { Text } from "@/components/text";
import { allEntries } from "@/data/contents";
import { Link } from "#src/components/link";
import { Text } from "#src/components/text";
import { allEntries } from "#src/data/contents";
import type { Metadata } from "next";

export const metadata = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/sized-box/sized-box.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cn } from "@/lib/utils";
import { cn } from "#src/lib/utils";
import type { ElementType, PropsWithChildren } from "react";

type Props = PropsWithChildren & {
Expand Down
2 changes: 1 addition & 1 deletion src/components/text/text.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cn } from "@/lib/utils";
import { cn } from "#src/lib/utils.js";
import type { PropsWithChildren } from "react";
import type { ComponentPropsWithoutRef, ElementType } from "react";

Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cn } from "@/lib/utils";
import { cn } from "#src/lib/utils";
import { Slot } from "@radix-ui/react-slot";
import { type VariantProps, cva } from "class-variance-authority";
import * as React from "react";
Expand Down
5 changes: 1 addition & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"target": "ESNext",
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"moduleResolution": "Node",
"moduleResolution": "Bundler",
"strict": true,
"esModuleInterop": true,
"noEmit": true,
Expand All @@ -16,9 +16,6 @@
"isolatedModules": true,
"incremental": false,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
},
"module": "esnext",
"resolveJsonModule": true,
"types": ["vitest/globals"],
Expand Down

0 comments on commit 739c38e

Please sign in to comment.