Skip to content

Commit

Permalink
Update tsconfig.json and update all imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpojer committed Oct 18, 2023
1 parent 8ac731d commit 39ffb8f
Show file tree
Hide file tree
Showing 19 changed files with 46 additions and 40 deletions.
1 change: 1 addition & 0 deletions packages/create-remdx/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// MIT License – Copyright (c) 2020-2021 Anthony Fu
import fs from 'node:fs';
import path from 'node:path';
// @ts-expect-error
import { execa } from 'execa';
import { blue, bold, dim, green, yellow } from 'kolorist';
import prompts from 'prompts';
Expand Down
6 changes: 3 additions & 3 deletions packages/create-remdx/template/slides.re.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sights from './sights';
import sights from './sights.tsx';

export { Components } from './Components';
export { Themes } from './Themes';
export { Components } from './Components.tsx';
export { Themes } from './Themes.tsx';

--
image: tokyo.jpg
Expand Down
7 changes: 4 additions & 3 deletions packages/create-remdx/template/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"compilerOptions": {
"allowJs": true,
"allowImportingTsExtensions": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"incremental": true,
"isolatedModules": true,
"jsx": "preserve",
"lib": ["dom", "dom.iterable", "esnext"],
"module": "esnext",
"moduleResolution": "node",
"module": "nodenext",
"moduleResolution": "nodenext",
"noEmit": true,
"noImplicitOverride": true,
"noUnusedLocals": true,
Expand All @@ -23,7 +24,7 @@
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "es2017"
"target": "es2022"
},
"exclude": ["dist/", "node_modules"],
"include": ["**/*.ts", "**/*.tsx"]
Expand Down
10 changes: 5 additions & 5 deletions packages/remdx/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ export type {
ReMDXSlide,
Themes,
MDXComponents as ComponentList,
} from './types';
} from './types.tsx';

export { default as Deck } from './src/deck';
export { default as render } from './src/render';
export { default as Slide } from './src/slide';
export { default as slidesToComponent } from './src/slidesToComponent';
export { default as Deck } from './src/deck.tsx';
export { default as render } from './src/render.tsx';
export { default as Slide } from './src/slide.tsx';
export { default as slidesToComponent } from './src/slidesToComponent.tsx';
export { useMDXComponents } from '@mdx-js/react';
5 changes: 5 additions & 0 deletions packages/remdx/src/components/Components.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { MDXComponents } from '../../types.tsx';
import Image from './Image.tsx';

const Components: MDXComponents = { img: Image };
export default Components;
5 changes: 0 additions & 5 deletions packages/remdx/src/components/index.tsx

This file was deleted.

10 changes: 5 additions & 5 deletions packages/remdx/src/deck.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {
useEffect,
} from 'react';
import { SwipeEventData } from 'react-swipeable';
import useAspectRatioFitting from './hooks/use-aspect-ratio-fitting';
import useDeckState from './hooks/use-deck-state';
import useLocationSync from './hooks/use-location-sync';
import useMousetrap from './hooks/use-mousetrap';
import { defaultTransition } from './transitions';
import useAspectRatioFitting from './hooks/use-aspect-ratio-fitting.tsx';
import useDeckState from './hooks/use-deck-state.tsx';
import useLocationSync from './hooks/use-location-sync.tsx';
import useMousetrap from './hooks/use-mousetrap.tsx';
import { defaultTransition } from './transitions.tsx';

export type SlideTransition = {
enter?: CSSProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default function useAspectRatioFitting(aspectRatio: number) {
recalculate(rects[0]);
}, [targetWidth, targetHeight, recalculate]);

// @ts-expect-error
useResizeObserver({
onResize: recalculate,
ref: containerRef,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createBrowserHistory, Location } from 'history';
import { useCallback, useEffect, useState } from 'react';
import { DeckView, GOTO_FINAL_STEP } from '../hooks/use-deck-state';
import { DeckView, GOTO_FINAL_STEP } from './use-deck-state.tsx';

export type SlideState = {
slideIndex?: number;
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions packages/remdx/src/render.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createRoot, Root } from 'react-dom/client';
import { ReMDXModule } from '../types';
import slidesToComponent from './slidesToComponent';
import { ReMDXModule } from '../types.tsx';
import slidesToComponent from './slidesToComponent.tsx';

const roots = new WeakMap<HTMLElement, Root>();

Expand Down
6 changes: 3 additions & 3 deletions packages/remdx/src/slide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
} from 'react';
import { animated, useSpring } from 'react-spring';
import { useSwipeable } from 'react-swipeable';
import { DeckContext, SlideTransition } from './deck';
import { GOTO_FINAL_STEP } from './hooks/use-deck-state';
import { Transitions } from './transitions';
import { DeckContext, SlideTransition } from './deck.tsx';
import { GOTO_FINAL_STEP } from './hooks/use-deck-state.tsx';
import { Transitions } from './transitions.tsx';

export default function Slide({
children,
Expand Down
10 changes: 5 additions & 5 deletions packages/remdx/src/slidesToComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { MDXProvider } from '@mdx-js/react';
import { ReMDXModule } from '../types';
import DefaultComponents from './components';
import Deck from './deck';
import Slide from './slide';
import { Transitions as DefaultTransitions } from './transitions';
import { ReMDXModule } from '../types.tsx';
import DefaultComponents from './components/Components.tsx';
import Deck from './deck.tsx';
import Slide from './slide.tsx';
import { Transitions as DefaultTransitions } from './transitions.tsx';

export default async function slidesToComponent(module: Promise<ReMDXModule>) {
const { Components, Themes, Transitions, default: slides } = await module;
Expand Down
2 changes: 1 addition & 1 deletion packages/remdx/src/transitions.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SlideTransition } from './deck';
import { SlideTransition } from './deck.tsx';

export const defaultTransition: SlideTransition = {
enter: {
Expand Down
2 changes: 1 addition & 1 deletion packages/remdx/types.ts → packages/remdx/types.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MDXProvider } from '@mdx-js/react';
import { CSSProperties } from 'react';
import { SlideTransition } from './src/deck';
import { SlideTransition } from './src/deck.tsx';

type MDXProps = typeof MDXProvider extends React.FC<infer Props>
? Props
Expand Down
3 changes: 2 additions & 1 deletion packages/vite-plugin-remdx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import normalizeNewline from 'normalize-newline';
import rehypeRaw from 'rehype-raw';
import shikiTwoslash, { setupForFile } from 'remark-shiki-twoslash';
import type { Plugin } from 'vite';
import ColorReplacements from './lib/ColorReplacements';
import ColorReplacements from './lib/ColorReplacements.tsx';

type Slide = [string, Record<string, unknown>];

Expand Down Expand Up @@ -169,6 +169,7 @@ export default function remdx(): Plugin {
return await transform(code, {
// @ts-expect-error
rehypePlugins: [[rehypeRaw, { passThrough: nodeTypes }]],
// @ts-expect-error
remarkPlugins: [[shikiTwoslashFn, shikiOptions]],
});
}
Expand Down
12 changes: 7 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"compilerOptions": {
"allowImportingTsExtensions": true,
"allowJs": true,
"allowImportingTsExtensions": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"incremental": true,
"isolatedModules": true,
"jsx": "react-jsx",
"jsx": "preserve",
"lib": ["dom", "dom.iterable", "esnext"],
"module": "esnext",
"moduleResolution": "node",
"module": "nodenext",
"moduleResolution": "nodenext",
"noEmit": true,
"noImplicitOverride": true,
"noUnusedLocals": true,
"plugins": [
{
Expand All @@ -23,7 +24,8 @@
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "es2020"
"target": "es2022",
"types": ["vite/client"]
},
"exclude": ["dist/", "node_modules", "packages/create-remdx/template"],
"ts-node": {
Expand Down

0 comments on commit 39ffb8f

Please sign in to comment.