remove .js in imports for now

pending https://github.com/esbuild-kit/tsx/issues/74
This commit is contained in:
itsMapleLeaf
2022-08-07 20:53:27 -05:00
parent d01c2a3bac
commit dc6239e598
18 changed files with 52 additions and 61 deletions

View File

@@ -43,7 +43,7 @@
}, },
"tsup": { "tsup": {
"entry": [ "entry": [
"library/main.ts" "src/main.ts"
], ],
"sourcemap": true, "sourcemap": true,
"target": "node16", "target": "node16",

View File

@@ -18,14 +18,14 @@ function isDeclarationPublic(declaration: Node) {
const project = new Project() const project = new Project()
project.addSourceFilesAtPaths(["library/**/*.{ts,tsx}", "!library/main.ts"]) project.addSourceFilesAtPaths(["src/**/*.{ts,tsx}", "!src/main.ts"])
const exportLines = project const exportLines = project
.getSourceFiles() .getSourceFiles()
.map((file) => { .map((file) => {
const importPath = relative( const importPath = relative(
"library", "src",
join(file.getDirectoryPath(), file.getBaseNameWithoutExtension() + ".js"), join(file.getDirectoryPath(), file.getBaseNameWithoutExtension()),
) )
const exports = file.getExportedDeclarations() const exports = file.getExportedDeclarations()
@@ -48,13 +48,13 @@ const exportLines = project
return `export { ${exportNames.join(", ")} } from "./${importPath}"` return `export { ${exportNames.join(", ")} } from "./${importPath}"`
}) })
const resolvedConfig = await prettier.resolveConfig("library/main.ts") const resolvedConfig = await prettier.resolveConfig("src/main.ts")
if (!resolvedConfig) { if (!resolvedConfig) {
throw new Error("Could not find prettier config") throw new Error("Could not find prettier config")
} }
await writeFile( await writeFile(
"library/main.ts", "src/main.ts",
prettier.format(exportLines.join(";"), { prettier.format(exportLines.join(";"), {
...resolvedConfig, ...resolvedConfig,
parser: "typescript", parser: "typescript",

View File

@@ -2,31 +2,27 @@ export {
type ReacordConfig, type ReacordConfig,
type InteractionInfo, type InteractionInfo,
ReacordClient, ReacordClient,
} from "./reacord-client.js" } from "./reacord-client"
export { type ReacordInstance } from "./reacord-instance.js" export { type ReacordInstance } from "./reacord-instance"
export { ActionRow, type ActionRowProps } from "./react/action-row.js" export { ActionRow, type ActionRowProps } from "./react/action-row"
export { type ButtonSharedProps } from "./react/button-shared-props.js" export { type ButtonSharedProps } from "./react/button-shared-props"
export { export { Button, type ButtonProps, type ButtonClickEvent } from "./react/button"
Button, export { type ComponentEvent } from "./react/component-event"
type ButtonProps, export { EmbedAuthor, type EmbedAuthorProps } from "./react/embed-author"
type ButtonClickEvent, export { EmbedField, type EmbedFieldProps } from "./react/embed-field"
} from "./react/button.js" export { EmbedFooter, type EmbedFooterProps } from "./react/embed-footer"
export { type ComponentEvent } from "./react/component-event.js" export { EmbedImage, type EmbedImageProps } from "./react/embed-image"
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"
export { export {
EmbedThumbnail, EmbedThumbnail,
type EmbedThumbnailProps, type EmbedThumbnailProps,
} from "./react/embed-thumbnail.js" } from "./react/embed-thumbnail"
export { EmbedTitle, type EmbedTitleProps } from "./react/embed-title.js" export { EmbedTitle, type EmbedTitleProps } from "./react/embed-title"
export { Embed, type EmbedProps } from "./react/embed.js" export { Embed, type EmbedProps } from "./react/embed"
export { useInstance } from "./react/instance-context.js" export { useInstance } from "./react/instance-context"
export { Link, type LinkProps } from "./react/link.js" export { Link, type LinkProps } from "./react/link"
export { Option, type OptionProps } from "./react/option.js" export { Option, type OptionProps } from "./react/option"
export { export {
Select, Select,
type SelectProps, type SelectProps,
type SelectChangeEvent, type SelectChangeEvent,
} from "./react/select.js" } from "./react/select"

View File

@@ -6,15 +6,10 @@ import {
} from "discord.js" } from "discord.js"
import * as React from "react" import * as React from "react"
import { createDiscordClient } from "./create-discord-client" import { createDiscordClient } from "./create-discord-client"
import type { ReacordInstance } from "./reacord-instance.js" import type { ReacordInstance } from "./reacord-instance"
import { ReacordInstancePrivate } from "./reacord-instance.js" import { ReacordInstancePrivate } from "./reacord-instance"
import { InstanceProvider } from "./react/instance-context" import { InstanceProvider } from "./react/instance-context"
import type { Renderer } from "./renderer.js" import { Renderer } from "./renderer"
import {
ChannelMessageRenderer,
EphemeralInteractionReplyRenderer,
InteractionReplyRenderer,
} from "./renderer.js"
/** /**
* @category Core * @category Core

View File

@@ -1,7 +1,7 @@
import type { ReactNode } from "react" import type { ReactNode } from "react"
import React from "react" import React from "react"
import { Node } from "../node.js" import { Node } from "../node"
import { ReacordElement } from "./reacord-element.js" import { ReacordElement } from "./reacord-element"
/** /**
* Props for an action row * Props for an action row

View File

@@ -1,10 +1,10 @@
import type { APIMessageComponentButtonInteraction } from "discord.js" import type { APIMessageComponentButtonInteraction } from "discord.js"
import { randomUUID } from "node:crypto" import { randomUUID } from "node:crypto"
import React from "react" import React from "react"
import { Node } from "../node.js" import { Node } from "../node"
import type { ButtonSharedProps } from "./button-shared-props" import type { ButtonSharedProps } from "./button-shared-props"
import type { ComponentEvent } from "./component-event.js" import type { ComponentEvent } from "./component-event"
import { ReacordElement } from "./reacord-element.js" import { ReacordElement } from "./reacord-element"
/** /**
* @category Button * @category Button

View File

@@ -1,5 +1,5 @@
import type { ReactNode } from "react" import type { ReactNode } from "react"
import type { ReacordInstance } from "../reacord-instance.js" import type { ReacordInstance } from "../reacord-instance"
/** /**
* @category Component Event * @category Component Event

View File

@@ -1,7 +1,7 @@
import type { ReactNode } from "react" import type { ReactNode } from "react"
import React from "react" import React from "react"
import { Node } from "../node.js" import { Node } from "../node"
import { ReacordElement } from "./reacord-element.js" import { ReacordElement } from "./reacord-element"
/** /**
* @category Embed * @category Embed

View File

@@ -1,7 +1,7 @@
import type { ReactNode } from "react" import type { ReactNode } from "react"
import React from "react" import React from "react"
import { Node } from "../node.js" import { Node } from "../node"
import { ReacordElement } from "./reacord-element.js" import { ReacordElement } from "./reacord-element"
/** /**
* @category Embed * @category Embed

View File

@@ -1,7 +1,7 @@
import type { ReactNode } from "react" import type { ReactNode } from "react"
import React from "react" import React from "react"
import { Node } from "../node.js" import { Node } from "../node"
import { ReacordElement } from "./reacord-element.js" import { ReacordElement } from "./reacord-element"
/** /**
* @category Embed * @category Embed

View File

@@ -1,6 +1,6 @@
import React from "react" import React from "react"
import { Node } from "../node" import { Node } from "../node"
import { ReacordElement } from "./reacord-element.js" import { ReacordElement } from "./reacord-element"
/** /**
* @category Embed * @category Embed

View File

@@ -1,6 +1,6 @@
import React from "react" import React from "react"
import { Node } from "../node" import { Node } from "../node"
import { ReacordElement } from "./reacord-element.js" import { ReacordElement } from "./reacord-element"
/** /**
* @category Embed * @category Embed

View File

@@ -2,7 +2,7 @@ import type { ReactNode } from "react"
import React from "react" import React from "react"
import type { Except } from "type-fest" import type { Except } from "type-fest"
import { Node } from "../node" import { Node } from "../node"
import { ReacordElement } from "./reacord-element.js" import { ReacordElement } from "./reacord-element"
/** /**
* @category Embed * @category Embed

View File

@@ -1,6 +1,6 @@
import React from "react" import React from "react"
import { Node } from "../node.js" import { Node } from "../node"
import { ReacordElement } from "./reacord-element.js" import { ReacordElement } from "./reacord-element"
/** /**
* @category Embed * @category Embed

View File

@@ -1,6 +1,6 @@
import { raise } from "@reacord/helpers/raise" import { raise } from "@reacord/helpers/raise"
import * as React from "react" 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) const Context = React.createContext<ReacordInstance | undefined>(undefined)

View File

@@ -1,8 +1,8 @@
import React from "react" import React from "react"
import type { Except } from "type-fest" import type { Except } from "type-fest"
import { Node } from "../node.js" import { Node } from "../node"
import type { ButtonSharedProps } from "./button-shared-props" import type { ButtonSharedProps } from "./button-shared-props"
import { ReacordElement } from "./reacord-element.js" import { ReacordElement } from "./reacord-element"
/** /**
* @category Link * @category Link

View File

@@ -1,9 +1,9 @@
/* eslint-disable unicorn/prefer-modern-dom-apis */ /* 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 ReactReconciler from "react-reconciler"
import { DefaultEventPriority } from "react-reconciler/constants" import { DefaultEventPriority } from "react-reconciler/constants"
import { Node, TextNode } from "../node.js" import { Node, TextNode } from "../node"
import type { ReacordInstancePrivate } from "../reacord-instance.js" import type { ReacordInstancePrivate } from "../reacord-instance"
export const reconciler = ReactReconciler< export const reconciler = ReactReconciler<
string, // Type, string, // Type,

View File

@@ -2,9 +2,9 @@ import type { APIMessageComponentSelectMenuInteraction } from "discord.js"
import { randomUUID } from "node:crypto" import { randomUUID } from "node:crypto"
import type { ReactNode } from "react" import type { ReactNode } from "react"
import React from "react" import React from "react"
import { Node } from "../node.js" import { Node } from "../node"
import type { ComponentEvent } from "./component-event.js" import type { ComponentEvent } from "./component-event"
import { ReacordElement } from "./reacord-element.js" import { ReacordElement } from "./reacord-element"
/** /**
* @category Select * @category Select