Skip to content
This repository has been archived by the owner on Feb 5, 2025. It is now read-only.

fix(pkg): fix esm export #1267

Merged
merged 3 commits into from
Jan 22, 2024
Merged

fix(pkg): fix esm export #1267

merged 3 commits into from
Jan 22, 2024

Conversation

baumstern
Copy link
Contributor

This PR ensures ESM modules are exported correctly, fixing the issue where using Remix with Vite leads to failed attempts to load CJS modules, as demonstrated in the case below:

(node:56711) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
2:26:48 AM [vite] Error when evaluating SSR module /app/routes/_index.tsx: failed to import "@hypercerts-org/sdk"
|- /Users/daehyun/workspace/pse/voicedeck/app/node_modules/.pnpm/@hypercerts-org+sdk@1.4.1_react@18.2.0_typescript@5.3.3/node_modules/@hypercerts-org/sdk/dist/esm/index.js:1
import { HypercertMinterAbi, deployments } from '@hypercerts-org/contracts';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:77:18)
    at wrapSafe (node:internal/modules/cjs/loader:1288:20)
    at Module._compile (node:internal/modules/cjs/loader:1340:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at cjsLoader (node:internal/modules/esm/translators:356:17)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:305:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async nodeImport (file:///Users/daehyun/workspace/pse/voicedeck/app/node_modules/.pnpm/vite@5.0.11/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:50899:17)
    at async ssrImport (file:///Users/daehyun/workspace/pse/voicedeck/app/node_modules/.pnpm/vite@5.0.11/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:50799:24)
    at async eval (/Users/daehyun/workspace/pse/voicedeck/app/app/routes/_index.tsx:6:31)
    at async instantiateModule (file:///Users/daehyun/workspace/pse/voicedeck/app/node_modules/.pnpm/vite@5.0.11/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:50861:9)

@bitbeckers bitbeckers changed the base branch from main to develop January 19, 2024 16:42
@bitbeckers
Copy link
Contributor

Taking in #1269 as well.

Released SDK 1.4.2.alpha-0 and contracts 1.1.1-alpha.0 for validating with other applications

@bitbeckers bitbeckers merged commit 94f810d into hypercerts-org:develop Jan 22, 2024
@bitbeckers
Copy link
Contributor

Merged. Thanks @baumstern for this PR

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants