mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
Fix package build with explicit index.js imports (#677)
<!--
Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md
-->
<!-- ELLIPSIS_HIDDEN -->
----
> [!IMPORTANT]
> Fixes ESM import issue by adding a plugin for implicit `index.js` and
renames interface files for consistency.
>
> - **Behavior**:
> - Adds `fixImportExtensions` plugin in `configs/tsup/js-library.ts` to
handle ESM imports with implicit `index.js`.
> - **Renames**:
> - Renames `adminInterface.ts` to `admin-interface.ts` and updates
imports in `index.ts` and `admin-app-impl.ts`.
> - Renames `clientInterface.ts` to `client-interface.ts` and updates
imports in `server-interface.ts`.
> - Renames `serverInterface.ts` to `server-interface.ts` and updates
imports in `adminInterface.ts`.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral)<sup>
for 1fcd668be4. You can
[customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this
summary. It will automatically update as commits are pushed.</sup>
<!-- ELLIPSIS_HIDDEN -->
---------
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Co-authored-by: Konsti Wohlwend <n2d4xc@gmail.com>
This commit is contained in:
parent
387c071501
commit
5265327176
@ -1,10 +1,35 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { defineConfig } from 'tsup';
|
||||
import { createBasePlugin } from './plugins';
|
||||
|
||||
|
||||
const customNoExternal = new Set([
|
||||
"oauth4webapi",
|
||||
]);
|
||||
|
||||
// https://github.com/egoist/tsup/issues/953
|
||||
const fixImportExtensions = (extension: string = ".js") => ({
|
||||
name: "fix-import-extensions",
|
||||
setup(build) {
|
||||
build.onResolve({ filter: /.*/ }, (args) => {
|
||||
if (args.importer) {
|
||||
const filePath = path.join(args.resolveDir, args.path);
|
||||
let resolvedPath;
|
||||
|
||||
|
||||
if (fs.existsSync(filePath + ".ts") || fs.existsSync(filePath + ".tsx")) {
|
||||
resolvedPath = args.path + extension;
|
||||
} else if (fs.existsSync(path.join(filePath, `index.ts`)) || fs.existsSync(path.join(filePath, `index.tsx`))) {
|
||||
resolvedPath = args.path.endsWith("/") ? args.path + "index" + extension : args.path + "/index" + extension;
|
||||
}
|
||||
return { path: resolvedPath ?? args.path, external: true };
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
export default function createJsLibraryTsupConfig(options: { barrelFile: boolean }) {
|
||||
return defineConfig({
|
||||
entryPoints: ['src/**/*.(ts|tsx|js|jsx)'],
|
||||
@ -16,6 +41,7 @@ export default function createJsLibraryTsupConfig(options: { barrelFile: boolean
|
||||
format: ['esm', 'cjs'],
|
||||
legacyOutput: true,
|
||||
esbuildPlugins: [
|
||||
fixImportExtensions(),
|
||||
createBasePlugin({}),
|
||||
{
|
||||
name: 'stackframe: force most files to be external',
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
export {
|
||||
StackAdminInterface
|
||||
} from "./interface/adminInterface";
|
||||
} from "./interface/admin-interface";
|
||||
export {
|
||||
StackClientInterface
|
||||
} from "./interface/clientInterface";
|
||||
} from "./interface/client-interface";
|
||||
export {
|
||||
StackServerInterface
|
||||
} from "./interface/serverInterface";
|
||||
} from "./interface/server-interface";
|
||||
export {
|
||||
KnownError,
|
||||
KnownErrors
|
||||
|
||||
@ -6,7 +6,7 @@ import { ProjectPermissionDefinitionsCrud } from "./crud/project-permissions";
|
||||
import { ProjectsCrud } from "./crud/projects";
|
||||
import { SvixTokenCrud } from "./crud/svix-token";
|
||||
import { TeamPermissionDefinitionsCrud } from "./crud/team-permissions";
|
||||
import { ServerAuthApplicationOptions, StackServerInterface } from "./serverInterface";
|
||||
import { ServerAuthApplicationOptions, StackServerInterface } from "./server-interface";
|
||||
|
||||
export type AdminAuthApplicationOptions = ServerAuthApplicationOptions &(
|
||||
| {
|
||||
@ -7,7 +7,7 @@ import { urlString } from "../utils/urls";
|
||||
import {
|
||||
ClientInterfaceOptions,
|
||||
StackClientInterface
|
||||
} from "./clientInterface";
|
||||
} from "./client-interface";
|
||||
import { ContactChannelsCrud } from "./crud/contact-channels";
|
||||
import { CurrentUserCrud } from "./crud/current-user";
|
||||
import { ConnectedAccountAccessTokenCrud } from "./crud/oauth";
|
||||
@ -1,6 +1,6 @@
|
||||
import { StackAdminInterface } from "@stackframe/stack-shared";
|
||||
import { getProductionModeErrors } from "@stackframe/stack-shared/dist/helpers/production-mode";
|
||||
import { InternalApiKeyCreateCrudResponse } from "@stackframe/stack-shared/dist/interface/adminInterface";
|
||||
import { InternalApiKeyCreateCrudResponse } from "@stackframe/stack-shared/dist/interface/admin-interface";
|
||||
import { EmailTemplateCrud, EmailTemplateType } from "@stackframe/stack-shared/dist/interface/crud/email-templates";
|
||||
import { InternalApiKeysCrud } from "@stackframe/stack-shared/dist/interface/crud/internal-api-keys";
|
||||
import { ProjectsCrud } from "@stackframe/stack-shared/dist/interface/crud/projects";
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { InternalApiKeyCreateCrudRequest } from "@stackframe/stack-shared/dist/interface/adminInterface";
|
||||
|
||||
import { InternalApiKeyCreateCrudRequest } from "@stackframe/stack-shared/dist/interface/admin-interface";
|
||||
import { InternalApiKeysCrud } from "@stackframe/stack-shared/dist/interface/crud/internal-api-keys";
|
||||
|
||||
export type InternalApiKeyBase = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user