Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adjust export map to be actually importable #62

Merged
merged 1 commit into from
Oct 13, 2023
Merged

Conversation

pieh
Copy link
Contributor

@pieh pieh commented Oct 13, 2023

Which problem is this pull request solving?

With current export map I am unable to actually import from @netlify/blobs. Both CJS and ESM ( https://gist.github.com/pieh/273d2341d3623a55b33069260e6fdaac ) are failing with

> node test.mjs
node:internal/errors:497
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /Users/misiek/test/netliblob-test/node_modules/@netlify/blobs/package.json imported from /Users/misiek/test/netliblob-test/test.mjs
    at new NodeError (node:internal/errors:406:5)
    at exportsNotFound (node:internal/modules/esm/resolve:268:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:542:13)
    at packageResolve (node:internal/modules/esm/resolve:772:14)
    at moduleResolve (node:internal/modules/esm/resolve:838:20)
    at defaultResolve (node:internal/modules/esm/resolve:1043:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:228:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

Node.js v20.8.0

Describe the solution you've chosen

Following https://www.typescriptlang.org/docs/handbook/esm-node.html#packagejson-exports-imports-and-self-referencing

Describe alternatives you've considered

Using following export map

  "exports": {
    ".": {
      "require": "./dist/main.cjs",
      "import": "./dist/main.js",
      "default": "./dist/main.js",
      "types": "./dist/main.d.ts"
    }
  },

but it was sharing types, which while should be exactly the same, approach in PR seems safer

Checklist

Please add a x inside each checkbox:

  • I have read the contribution guidelines.
  • The status checks are successful (continuous integration). Those can be seen below.

@pieh pieh requested a review from a team as a code owner October 13, 2023 08:50
@netlify
Copy link

netlify bot commented Oct 13, 2023

Deploy Preview for blobs-js ready!

Name Link
🔨 Latest commit 07380ef
🔍 Latest deploy log https://app.netlify.com/sites/blobs-js/deploys/652904d3c834760008a11bc1
😎 Deploy Preview https://deploy-preview-62--blobs-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions github-actions bot added the type: bug code to address defects in shipped code label Oct 13, 2023
@Skn0tt Skn0tt merged commit 1bedfde into main Oct 13, 2023
21 checks passed
@eduardoboucas eduardoboucas deleted the fix/export-map branch October 24, 2023 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants