Skip to content

Commit

Permalink
remove .js in imports for now
Browse files Browse the repository at this point in the history
  • Loading branch information
itsMapleLeaf committed Aug 8, 2022
1 parent d01c2a3 commit dc6239e
Show file tree
Hide file tree
Showing 18 changed files with 52 additions and 61 deletions.
2 changes: 1 addition & 1 deletion packages/reacord/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
"tsup": {
"entry": [
"library/main.ts"
"src/main.ts"
],
"sourcemap": true,
"target": "node16",
Expand Down
10 changes: 5 additions & 5 deletions packages/reacord/scripts/generate-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ function isDeclarationPublic(declaration: Node) {

const project = new Project()

project.addSourceFilesAtPaths(["library/**/*.{ts,tsx}", "!library/main.ts"])
project.addSourceFilesAtPaths(["src/**/*.{ts,tsx}", "!src/main.ts"])

const exportLines = project
.getSourceFiles()
.map((file) => {
const importPath = relative(
"library",
join(file.getDirectoryPath(), file.getBaseNameWithoutExtension() + ".js"),
"src",
join(file.getDirectoryPath(), file.getBaseNameWithoutExtension()),
)
const exports = file.getExportedDeclarations()

Expand All @@ -48,13 +48,13 @@ const exportLines = project
return `export { ${exportNames.join(", ")} } from "./${importPath}"`
})

const resolvedConfig = await prettier.resolveConfig("library/main.ts")
const resolvedConfig = await prettier.resolveConfig("src/main.ts")
if (!resolvedConfig) {
throw new Error("Could not find prettier config")
}

await writeFile(
"library/main.ts",
"src/main.ts",
prettier.format(exportLines.join(";"), {
...resolvedConfig,
parser: "typescript",
Expand Down
38 changes: 17 additions & 21 deletions packages/reacord/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,27 @@ export {
type ReacordConfig,
type InteractionInfo,
ReacordClient,
} from "./reacord-client.js"
export { type ReacordInstance } from "./reacord-instance.js"
export { ActionRow, type ActionRowProps } from "./react/action-row.js"
export { type ButtonSharedProps } from "./react/button-shared-props.js"
export {
Button,
type ButtonProps,
type ButtonClickEvent,
} from "./react/button.js"
export { type ComponentEvent } from "./react/component-event.js"
export { EmbedAuthor, type EmbedAuthorProps } from "./react/embed-author.js"
export { EmbedField, type EmbedFieldProps } from "./react/embed-field.js"
export { EmbedFooter, type EmbedFooterProps } from "./react/embed-footer.js"
export { EmbedImage, type EmbedImageProps } from "./react/embed-image.js"
} from "./reacord-client"
export { type ReacordInstance } from "./reacord-instance"
export { ActionRow, type ActionRowProps } from "./react/action-row"
export { type ButtonSharedProps } from "./react/button-shared-props"
export { Button, type ButtonProps, type ButtonClickEvent } from "./react/button"
export { type ComponentEvent } from "./react/component-event"
export { EmbedAuthor, type EmbedAuthorProps } from "./react/embed-author"
export { EmbedField, type EmbedFieldProps } from "./react/embed-field"
export { EmbedFooter, type EmbedFooterProps } from "./react/embed-footer"
export { EmbedImage, type EmbedImageProps } from "./react/embed-image"
export {
EmbedThumbnail,
type EmbedThumbnailProps,
} from "./react/embed-thumbnail.js"
export { EmbedTitle, type EmbedTitleProps } from "./react/embed-title.js"
export { Embed, type EmbedProps } from "./react/embed.js"
export { useInstance } from "./react/instance-context.js"
export { Link, type LinkProps } from "./react/link.js"
export { Option, type OptionProps } from "./react/option.js"
} from "./react/embed-thumbnail"
export { EmbedTitle, type EmbedTitleProps } from "./react/embed-title"
export { Embed, type EmbedProps } from "./react/embed"
export { useInstance } from "./react/instance-context"
export { Link, type LinkProps } from "./react/link"
export { Option, type OptionProps } from "./react/option"
export {
Select,
type SelectProps,
type SelectChangeEvent,
} from "./react/select.js"
} from "./react/select"
11 changes: 3 additions & 8 deletions packages/reacord/src/reacord-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@ import {
} from "discord.js"
import * as React from "react"
import { createDiscordClient } from "./create-discord-client"
import type { ReacordInstance } from "./reacord-instance.js"
import { ReacordInstancePrivate } from "./reacord-instance.js"
import type { ReacordInstance } from "./reacord-instance"
import { ReacordInstancePrivate } from "./reacord-instance"
import { InstanceProvider } from "./react/instance-context"
import type { Renderer } from "./renderer.js"
import {
ChannelMessageRenderer,
EphemeralInteractionReplyRenderer,
InteractionReplyRenderer,
} from "./renderer.js"
import { Renderer } from "./renderer"

/**
* @category Core
Expand Down
4 changes: 2 additions & 2 deletions packages/reacord/src/react/action-row.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ReactNode } from "react"
import React from "react"
import { Node } from "../node.js"
import { ReacordElement } from "./reacord-element.js"
import { Node } from "../node"
import { ReacordElement } from "./reacord-element"

/**
* Props for an action row
Expand Down
6 changes: 3 additions & 3 deletions packages/reacord/src/react/button.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { APIMessageComponentButtonInteraction } from "discord.js"
import { randomUUID } from "node:crypto"
import React from "react"
import { Node } from "../node.js"
import { Node } from "../node"
import type { ButtonSharedProps } from "./button-shared-props"
import type { ComponentEvent } from "./component-event.js"
import { ReacordElement } from "./reacord-element.js"
import type { ComponentEvent } from "./component-event"
import { ReacordElement } from "./reacord-element"

/**
* @category Button
Expand Down
2 changes: 1 addition & 1 deletion packages/reacord/src/react/component-event.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ReactNode } from "react"
import type { ReacordInstance } from "../reacord-instance.js"
import type { ReacordInstance } from "../reacord-instance"

/**
* @category Component Event
Expand Down
4 changes: 2 additions & 2 deletions packages/reacord/src/react/embed-author.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ReactNode } from "react"
import React from "react"
import { Node } from "../node.js"
import { ReacordElement } from "./reacord-element.js"
import { Node } from "../node"
import { ReacordElement } from "./reacord-element"

/**
* @category Embed
Expand Down
4 changes: 2 additions & 2 deletions packages/reacord/src/react/embed-field.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ReactNode } from "react"
import React from "react"
import { Node } from "../node.js"
import { ReacordElement } from "./reacord-element.js"
import { Node } from "../node"
import { ReacordElement } from "./reacord-element"

/**
* @category Embed
Expand Down
4 changes: 2 additions & 2 deletions packages/reacord/src/react/embed-footer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ReactNode } from "react"
import React from "react"
import { Node } from "../node.js"
import { ReacordElement } from "./reacord-element.js"
import { Node } from "../node"
import { ReacordElement } from "./reacord-element"

/**
* @category Embed
Expand Down
2 changes: 1 addition & 1 deletion packages/reacord/src/react/embed-image.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react"
import { Node } from "../node"
import { ReacordElement } from "./reacord-element.js"
import { ReacordElement } from "./reacord-element"

/**
* @category Embed
Expand Down
2 changes: 1 addition & 1 deletion packages/reacord/src/react/embed-thumbnail.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react"
import { Node } from "../node"
import { ReacordElement } from "./reacord-element.js"
import { ReacordElement } from "./reacord-element"

/**
* @category Embed
Expand Down
2 changes: 1 addition & 1 deletion packages/reacord/src/react/embed-title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ReactNode } from "react"
import React from "react"
import type { Except } from "type-fest"
import { Node } from "../node"
import { ReacordElement } from "./reacord-element.js"
import { ReacordElement } from "./reacord-element"

/**
* @category Embed
Expand Down
4 changes: 2 additions & 2 deletions packages/reacord/src/react/embed.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react"
import { Node } from "../node.js"
import { ReacordElement } from "./reacord-element.js"
import { Node } from "../node"
import { ReacordElement } from "./reacord-element"

/**
* @category Embed
Expand Down
2 changes: 1 addition & 1 deletion packages/reacord/src/react/instance-context.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { raise } from "@reacord/helpers/raise"
import * as React from "react"
import type { ReacordInstance } from "../reacord-instance.js"
import type { ReacordInstance } from "../reacord-instance"

const Context = React.createContext<ReacordInstance | undefined>(undefined)

Expand Down
4 changes: 2 additions & 2 deletions packages/reacord/src/react/link.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from "react"
import type { Except } from "type-fest"
import { Node } from "../node.js"
import { Node } from "../node"
import type { ButtonSharedProps } from "./button-shared-props"
import { ReacordElement } from "./reacord-element.js"
import { ReacordElement } from "./reacord-element"

/**
* @category Link
Expand Down
6 changes: 3 additions & 3 deletions packages/reacord/src/react/reconciler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable unicorn/prefer-modern-dom-apis */
import { raise } from "@reacord/helpers/raise.js"
import { raise } from "@reacord/helpers/raise"
import ReactReconciler from "react-reconciler"
import { DefaultEventPriority } from "react-reconciler/constants"
import { Node, TextNode } from "../node.js"
import type { ReacordInstancePrivate } from "../reacord-instance.js"
import { Node, TextNode } from "../node"
import type { ReacordInstancePrivate } from "../reacord-instance"

export const reconciler = ReactReconciler<
string, // Type,
Expand Down
6 changes: 3 additions & 3 deletions packages/reacord/src/react/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { APIMessageComponentSelectMenuInteraction } from "discord.js"
import { randomUUID } from "node:crypto"
import type { ReactNode } from "react"
import React from "react"
import { Node } from "../node.js"
import type { ComponentEvent } from "./component-event.js"
import { ReacordElement } from "./reacord-element.js"
import { Node } from "../node"
import type { ComponentEvent } from "./component-event"
import { ReacordElement } from "./reacord-element"

/**
* @category Select
Expand Down

0 comments on commit dc6239e

Please sign in to comment.