Skip to content

Commit

Permalink
Fix cjs import path resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
ije committed Jan 28, 2023
1 parent e36c277 commit 427edfa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/esm-node-services/cjs-lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function verifyExports(names) {

exports.parseCjsExports = async input => {
const { buildDir, importPath, nodeEnv = "production", requireMode } = input
const entry = /\.(js|cjs|mjs)$/.test(importPath) ? join(buildDir, "node_modules", importPath) : await resolve(buildDir, importPath)
const entry = importPath.startsWith("/") && /\.(js|cjs|mjs)$/.test(importPath) ? importPath : await resolve(buildDir, importPath)
const exports = []

if (requireMode) {
Expand All @@ -121,7 +121,7 @@ exports.parseCjsExports = async input => {
return verifyExports(getJSONKeys(entry))
}

if (!entry.endsWith(".js") && !entry.endsWith(".cjs")) {
if (!entry.endsWith(".js") && !entry.endsWith(".cjs") && !entry.endsWith(".mjs")) {
return verifyExports(exports)
}

Expand Down
4 changes: 2 additions & 2 deletions packages/esm-node-services/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/esm-node-services/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "esm-node-services",
"version": "0.7.10",
"version": "0.7.11",
"description": "Node services for esm.sh",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 427edfa

Please sign in to comment.