From acb7ee307418514e22651ef8984ab4027a687eba Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Wed, 31 Jul 2024 14:42:31 -0400 Subject: [PATCH] fix generate --- .monorepolint.config.mjs | 1 + .../generateMockOntology.js | 2 ++ packages/e2e.test.foundry-sdk-generator/package.json | 8 +++----- .../src/GeneratePackageCommand.test.ts | 3 +-- packages/e2e.test.foundry-sdk-generator/tsup.config.js | 4 +++- packages/monorepo.tsup/tsup.mjs | 1 + 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.monorepolint.config.mjs b/.monorepolint.config.mjs index d7379b62f..4684ac475 100644 --- a/.monorepolint.config.mjs +++ b/.monorepolint.config.mjs @@ -499,6 +499,7 @@ NOTE: DO NOT EDIT THIS README BY HAND. It is generated by monorepolint. includePackages: ["@osdk/e2e.test.foundry-sdk-generator"], }, { legacy: false, + esmOnly: true, tsVersion: LATEST_TYPESCRIPT_DEP, customTsconfigExcludes: [ "./src/generatedNoCheck/**/*", diff --git a/packages/e2e.test.foundry-sdk-generator/generateMockOntology.js b/packages/e2e.test.foundry-sdk-generator/generateMockOntology.js index 524720ca1..762028b38 100644 --- a/packages/e2e.test.foundry-sdk-generator/generateMockOntology.js +++ b/packages/e2e.test.foundry-sdk-generator/generateMockOntology.js @@ -38,6 +38,8 @@ async function setup() { await safeStat(testAppDir, "should not exist"); await safeStat(testApp2Dir, "should not exist"); + await fs.mkdir(dir, { recursive: true }); + const generatePackageCommand = new GeneratePackageCommand(); await generatePackageCommand.handler({ packageName: "@test-app/osdk", diff --git a/packages/e2e.test.foundry-sdk-generator/package.json b/packages/e2e.test.foundry-sdk-generator/package.json index 1522fefbe..21e38193d 100644 --- a/packages/e2e.test.foundry-sdk-generator/package.json +++ b/packages/e2e.test.foundry-sdk-generator/package.json @@ -9,18 +9,16 @@ }, "exports": { ".": { - "require": "./build/cjs/index.cjs", "browser": "./build/browser/index.js", "import": "./build/esm/index.js" }, "./*": { - "require": "./build/cjs/public/*.cjs", "browser": "./build/browser/public/*.js", "import": "./build/esm/public/*.js" } }, "scripts": { - "check-attw": "monorepo.tool.attw both", + "check-attw": "monorepo.tool.attw esm", "check-spelling": "cspell --quiet .", "clean": "rm -rf lib dist types build tsconfig.tsbuildinfo", "codegen": "node ./generateMockOntology.js", @@ -28,7 +26,7 @@ "lint": "eslint . && dprint check --config $(find-up dprint.json)", "test": "vitest run --pool=forks", "transpile": "monorepo.tool.transpile", - "typecheck": "monorepo.tool.typecheck both" + "typecheck": "monorepo.tool.typecheck esm" }, "dependencies": { "@osdk/foundry-sdk-generator": "workspace:~", @@ -56,6 +54,6 @@ ], "main": "./build/cjs/index.cjs", "module": "./build/esm/index.js", - "types": "./build/cjs/index.d.cts", + "types": "./build/esm/index.d.ts", "type": "module" } diff --git a/packages/e2e.test.foundry-sdk-generator/src/GeneratePackageCommand.test.ts b/packages/e2e.test.foundry-sdk-generator/src/GeneratePackageCommand.test.ts index 8a8266977..dac5b9310 100644 --- a/packages/e2e.test.foundry-sdk-generator/src/GeneratePackageCommand.test.ts +++ b/packages/e2e.test.foundry-sdk-generator/src/GeneratePackageCommand.test.ts @@ -14,14 +14,13 @@ * limitations under the License. */ -import { __testSeamOnly_NotSemverStable__GeneratePackageCommand as GeneratePackageCommand } from "@osdk/foundry-sdk-generator"; import { existsSync } from "node:fs"; import * as fs from "node:fs/promises"; import * as path from "node:path"; import { fileURLToPath } from "node:url"; import { describe, expect, it } from "vitest"; -describe(GeneratePackageCommand, () => { +describe("Generate Package Command", () => { // ensure that we do not break backcompat by retaining our scripts export that links to the bundled types and esm output it("has a public scripts export", async () => { const generatedPath = path.join( diff --git a/packages/e2e.test.foundry-sdk-generator/tsup.config.js b/packages/e2e.test.foundry-sdk-generator/tsup.config.js index 7a77e08bc..cfc2b707b 100644 --- a/packages/e2e.test.foundry-sdk-generator/tsup.config.js +++ b/packages/e2e.test.foundry-sdk-generator/tsup.config.js @@ -17,5 +17,7 @@ import { defineConfig } from "tsup"; export default defineConfig(async (options) => - (await import("@osdk/monorepo.tsup")).default(options, {}) + (await import("@osdk/monorepo.tsup")).default(options, { + esmOnly: true, + }) ); diff --git a/packages/monorepo.tsup/tsup.mjs b/packages/monorepo.tsup/tsup.mjs index 1c4892d42..b475f46b6 100644 --- a/packages/monorepo.tsup/tsup.mjs +++ b/packages/monorepo.tsup/tsup.mjs @@ -44,6 +44,7 @@ export default async (options, ourOptions) => { silent: true, sourcemap: true, splitting: true, + shims: true, // so we can use __dirname in both esm and cjs minify: false, // !options.watch, onSuccess: async () => { console.log("👍");