-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #703 from oBusk/app-directory
Next.js 13 - App directory
- Loading branch information
Showing
153 changed files
with
1,794 additions
and
1,439 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ node_modules | |
.next | ||
.vscode/.chrome | ||
coverage/ | ||
static/media/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
import "@testing-library/jest-dom/extend-expect"; | ||
|
||
// Override the react.cache method to avoid caching in tests | ||
jest.mock("react", () => { | ||
const React = jest.requireActual("react"); | ||
React.cache = (fn) => fn; | ||
return React; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
/** @type {import('next').NextConfig} */ | ||
module.exports = { | ||
reactStrictMode: true, | ||
compiler: { | ||
emotion: true, | ||
// Does not work with appDir | ||
// https://beta.nextjs.org/docs/styling/css-in-js | ||
// compiler: { | ||
// emotion: true, | ||
// }, | ||
experimental: { | ||
serverComponentsExternalPackages: [ | ||
"libnpmdiff", | ||
"npm-package-arg", | ||
"pacote", | ||
], | ||
appDir: true, | ||
}, | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions
6
src/components/ErrorBox.tsx → src/app/[...parts]/_error/ErrorBox.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import bundlephobia from "^/lib/api/bundlephobia"; | ||
import TIMED_OUT from "^/lib/api/TimedOut"; | ||
import { Bundlephobia } from "^/lib/Services"; | ||
import SimplePackageSpec from "^/lib/SimplePackageSpec"; | ||
import measuredPromise from "^/lib/utils/measuredPromise"; | ||
import BundlephobiaFlags, { | ||
BundlephobiaFlagsSkeleton, | ||
} from "./DiffIntro/BundlePhobiaFlags"; | ||
import SizeComparison, { SizeComparisonSkeleton } from "./SizeComparison"; | ||
|
||
export interface BundlephobiaDiffProps { | ||
a: SimplePackageSpec; | ||
b: SimplePackageSpec; | ||
specs: [string, string]; | ||
} | ||
|
||
const { name } = Bundlephobia; | ||
|
||
const BundlephobiaDiff = async ({ specs, a, b }: BundlephobiaDiffProps) => { | ||
const { result, time } = await measuredPromise(bundlephobia(specs)); | ||
|
||
if (result == null) { | ||
console.warn(`${name} result is null`, { specs }); | ||
return null; | ||
} | ||
|
||
if (result === TIMED_OUT) { | ||
console.warn(`${name} timed out`, { specs }); | ||
return null; | ||
} | ||
|
||
console.log(name, { specs, time }); | ||
|
||
return ( | ||
<SizeComparison | ||
serviceName={name} | ||
flags={<BundlephobiaFlags data={result} />} | ||
a={a} | ||
b={b} | ||
sizeRows={[ | ||
{ | ||
name: "Size", | ||
a: { | ||
bytes: result.a.size, | ||
}, | ||
b: { | ||
bytes: result.b.size, | ||
}, | ||
}, | ||
{ | ||
name: "Gzip", | ||
a: { | ||
bytes: result.a.gzip, | ||
}, | ||
b: { | ||
bytes: result.b.gzip, | ||
}, | ||
}, | ||
{ | ||
name: "Dependencies", | ||
a: { | ||
count: result.a.dependencyCount, | ||
}, | ||
b: { | ||
count: result.b.dependencyCount, | ||
}, | ||
}, | ||
]} | ||
/> | ||
); | ||
}; | ||
|
||
export default BundlephobiaDiff; | ||
|
||
export const BundlephobiaDiffSkeleton = () => ( | ||
<SizeComparisonSkeleton | ||
serviceName={name} | ||
flags={<BundlephobiaFlagsSkeleton />} | ||
sizeRows={[ | ||
{ | ||
name: "Size", | ||
a: 42, | ||
b: 84, | ||
}, | ||
{ | ||
name: "Gzip", | ||
a: 42, | ||
b: 84, | ||
}, | ||
{ | ||
name: "Dependencies", | ||
a: 16, | ||
b: 32, | ||
}, | ||
]} | ||
/> | ||
); |
2 changes: 2 additions & 0 deletions
2
...o/BundlePhobiaFlags/BundlePhobiaFlags.tsx → ...o/BundlePhobiaFlags/BundlePhobiaFlags.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/app/[...parts]/_page/DiffIntro/BundlePhobiaFlags/BundlePhobiaFlagsSkeleton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"use client"; | ||
|
||
import { HStack } from "@chakra-ui/react"; | ||
import { FlagSkeleton } from "./Flag"; | ||
|
||
const BundlephobiaFlagsSkeleton = () => ( | ||
<HStack> | ||
<FlagSkeleton /> | ||
<FlagSkeleton /> | ||
</HStack> | ||
); | ||
|
||
export default BundlephobiaFlagsSkeleton; |
55 changes: 55 additions & 0 deletions
55
src/app/[...parts]/_page/DiffIntro/BundlePhobiaFlags/Flag.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { | ||
forwardRef, | ||
Skeleton, | ||
Tag, | ||
TagLabel, | ||
TagLeftIcon, | ||
TagProps, | ||
} from "@chakra-ui/react"; | ||
import { ElementType, ReactNode } from "react"; | ||
import Tooltip from "^/components/Tooltip"; | ||
import TreeshakeIcon from "./assets/TreeshakeIcon"; | ||
|
||
interface FlagProps extends TagProps { | ||
icon: ElementType; | ||
label: string; | ||
tooltip?: ReactNode; | ||
colorScheme?: undefined | "green" | "red"; | ||
} | ||
|
||
const Flag = forwardRef<FlagProps, "div">( | ||
({ label, icon, tooltip, colorScheme, ...props }, ref) => { | ||
const tag = ( | ||
<Tag | ||
colorScheme={colorScheme} | ||
cursor="help" | ||
margin="10px 0" | ||
{...props} | ||
ref={ref} | ||
> | ||
<TagLeftIcon boxSize="16px" as={icon} fill="currentColor" /> | ||
<TagLabel>{label}</TagLabel> | ||
</Tag> | ||
); | ||
|
||
if (tooltip == null) { | ||
return tag; | ||
} | ||
|
||
return ( | ||
<Tooltip | ||
label={tooltip} | ||
closeOnClick={false} | ||
shouldWrapChildren={true} | ||
> | ||
{tag} | ||
</Tooltip> | ||
); | ||
}, | ||
); | ||
|
||
export default Flag; | ||
|
||
export const FlagSkeleton = () => ( | ||
<Skeleton margin="10px 0" width="130px" height="24px" /> | ||
); |
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions
5
src/app/[...parts]/_page/DiffIntro/BundlePhobiaFlags/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import BundlephobiaFlags, { BundlephobiaFlagsProps } from "./BundlePhobiaFlags"; | ||
import BundlephobiaFlagsSkeleton from "./BundlePhobiaFlagsSkeleton"; | ||
|
||
export default BundlephobiaFlags; | ||
export { BundlephobiaFlagsSkeleton, type BundlephobiaFlagsProps }; |
4 changes: 2 additions & 2 deletions
4
src/components/DiffIntro/Command.tsx → ...pp/[...parts]/_page/DiffIntro/Command.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
"use client"; | ||
|
||
import { | ||
Box, | ||
Code, | ||
Flex, | ||
FlexProps, | ||
forwardRef, | ||
Heading, | ||
Text, | ||
} from "@chakra-ui/react"; | ||
import { ReactNode } from "react"; | ||
import { NpmDiffOptions } from "^/lib/npmDiff"; | ||
import SimplePackageSpec from "^/lib/SimplePackageSpec"; | ||
import contentVisibility from "^/lib/utils/contentVisibility"; | ||
import Halfs from "./Halfs"; | ||
import Options from "./Options"; | ||
import SpecBox from "./SpecBox"; | ||
|
||
export interface DiffIntroProps extends FlexProps { | ||
a: SimplePackageSpec; | ||
b: SimplePackageSpec; | ||
services: ReactNode; | ||
options: NpmDiffOptions; | ||
} | ||
|
||
const DiffIntro = forwardRef<DiffIntroProps, "h2">( | ||
({ a, b, services, options, ...props }, ref) => { | ||
if (a.name == null) { | ||
a.name = "ERROR"; | ||
} | ||
if (b.name == null) { | ||
b.name = "ERROR"; | ||
} | ||
|
||
return ( | ||
<Flex | ||
direction="column" | ||
alignItems="center" | ||
css={{ | ||
label: "DiffIntro", | ||
...contentVisibility("700px"), | ||
}} | ||
{...props} | ||
ref={ref} | ||
> | ||
<Heading | ||
as="h2" | ||
size="sm" | ||
width="100%" | ||
textAlign="center" | ||
marginBottom="1.5em" | ||
> | ||
<Text>Comparing </Text> | ||
<Halfs | ||
left={<SpecBox pkg={a} />} | ||
center={ | ||
<Box> | ||
{/* Center column */} | ||
<Code>...</Code> | ||
</Box> | ||
} | ||
right={<SpecBox pkg={b} />} | ||
/> | ||
</Heading> | ||
{services} | ||
<Heading size="l">npm diff</Heading> | ||
<Options options={options} /> | ||
{/* <Command | ||
aName={aName} | ||
aVersion={aVersion} | ||
bName={bName} | ||
bVersion={bVersion} | ||
options={options} | ||
/> */} | ||
</Flex> | ||
); | ||
}, | ||
); | ||
|
||
export default DiffIntro; |
7 changes: 4 additions & 3 deletions
7
src/components/DiffIntro/Halfs.tsx → src/app/[...parts]/_page/DiffIntro/Halfs.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/components/DiffIntro/Options.tsx → ...pp/[...parts]/_page/DiffIntro/Options.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
00439c4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
npm-diff – ./
npm-diff.vercel.app
package-diff.vercel.app
npm-diff-obusk.vercel.app
npm-diff-git-main-obusk.vercel.app
www.npm-diff.com
www.npm-diff.app
npm-diff.app
npm-diff.com