Skip to content

Commit 27f3f3e

Browse files
authored
Merge pull request #269 from cyntler/vite-migration
build: migrate build process to vite library mode
2 parents 105f3a8 + c5d901f commit 27f3f3e

File tree

15 files changed

+654
-66
lines changed

15 files changed

+654
-66
lines changed

package-lock.json

Lines changed: 595 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@
1818
"files": [
1919
"dist/**"
2020
],
21-
"types": "./dist/esm/index.d.ts",
22-
"main": "./dist/cjs/index.js",
23-
"module": "./dist/esm/index.js",
21+
"types": "./dist/index.d.ts",
22+
"main": "./dist/react-doc-viewer.cjs",
23+
"module": "./dist/react-doc-viewer.js",
2424
"exports": {
25-
"require": "./dist/cjs/index.js",
26-
"import": "./dist/esm/index.js"
25+
".": {
26+
"require": "./dist/react-doc-viewer.cjs",
27+
"import": "./dist/react-doc-viewer.js",
28+
"types": "./dist/index.d.ts"
29+
}
2730
},
2831
"scripts": {
2932
"start": "storybook dev -p 6006",
30-
"build": "rm -rf dist && npm run build:esm && npm run build:cjs",
31-
"build:esm": "tsc --project tsconfig.build.json",
32-
"build:cjs": "tsc --project tsconfig.build.json --module commonjs --moduleResolution node --verbatimModuleSyntax false --outDir ./dist/cjs",
33-
"postbuild:cjs": "echo '{\n \"type\": \"commonjs\"\n}' > dist/cjs/package.json",
33+
"build": "rm -rf dist && tsc && vite build",
3434
"test": "vitest run",
3535
"lint": "eslint ./src --ext .ts,.tsx",
3636
"prettier:check": "prettier --check .",
@@ -85,6 +85,8 @@
8585
"release-it": "^17.3.0",
8686
"storybook": "^8.1.5",
8787
"typescript": "^5.4.5",
88+
"vite": "^5.2.12",
89+
"vite-plugin-dts": "^3.9.1",
8890
"vitest": "^1.6.0",
8991
"vitest-fetch-mock": "^0.2.2",
9092
"webpack": "^5.91.0"

src/components/DocumentNav.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import React, { FC, useContext } from "react";
1+
"use client";
2+
3+
import { FC, useContext } from "react";
24
import styled from "styled-components";
35
import { DocViewerContext } from "../store/DocViewerProvider";
46
import { nextDocument, previousDocument } from "../store/actions";

src/components/FileName.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import React, { FC, useContext } from "react";
1+
"use client";
2+
3+
import { FC, useContext } from "react";
24
import styled from "styled-components";
35
import { DocViewerContext } from "../store/DocViewerProvider";
46
import { IStyledProps } from "..";

src/components/HeaderBar.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import React, { FC, useContext } from "react";
1+
"use client";
2+
3+
import { FC, useContext } from "react";
24
import styled from "styled-components";
35
import { DocViewerContext } from "../store/DocViewerProvider";
46
import { nextDocument, previousDocument } from "../store/actions";

src/components/LoadingTimout.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import React, {
2-
FC,
3-
PropsWithChildren,
4-
useContext,
5-
useEffect,
6-
useState,
7-
} from "react";
1+
"use client";
2+
3+
import { FC, PropsWithChildren, useContext, useEffect, useState } from "react";
84
import { DocViewerContext } from "../store/DocViewerProvider";
95

106
export const LoadingTimeout: FC<PropsWithChildren> = ({ children }) => {

src/components/ProxyRenderer.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import React, { FC, useCallback } from "react";
1+
"use client";
2+
3+
import { FC, useCallback } from "react";
24
import styled, { keyframes } from "styled-components";
35
import { setRendererRect } from "../store/actions";
46
import { DocRenderer, IConfig, IDocument, IStyledProps } from "../models";

src/components/icons/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
"use client";
22

33
export interface IIconProps {
44
color?: string;

src/cssStyles.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import "react-pdf/dist/esm/Page/AnnotationLayer.css";
2+
import "react-pdf/dist/esm/Page/TextLayer.css";

src/i18n.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ export const locales = {
2929
};
3030

3131
export type AvailableLanguages = keyof typeof locales;
32+
3233
export const defaultLanguage: AvailableLanguages = "en";

0 commit comments

Comments
 (0)