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

Point to the correct file #16

Merged
merged 1 commit into from
Apr 13, 2023
Merged

Point to the correct file #16

merged 1 commit into from
Apr 13, 2023

Conversation

svedova
Copy link
Contributor

@svedova svedova commented Apr 13, 2023

We should point to the correct file otherwise commonjs plugin may fail to resolve the module.

I receive the following error when I'm trying to build using Vite:

[commonjs--resolver] Failed to resolve entry for package "function-bind". The package may have incorrect main/module/exports specified in its package.json.

Updating the package.json fixes it.

My workaround till package.json is updated is as follows:

// vite config

resolve: {
  alias: [
    {
      find: /function-bind/,
      replacement: path.resolve(__dirname, "node_modules", "function-bind", "index.js")
    }
  ]
}

We should point to the correct file otherwise `commonjs` plugin may fail to resolve the module.
@svedova
Copy link
Contributor Author

svedova commented Apr 13, 2023

@Raynos / @ljharb do you have the capacity to review this PR?

@Raynos
Copy link
Owner

Raynos commented Apr 13, 2023

Fun story, I'm locked out of my npm account and cannot npm publish :D

@Raynos Raynos merged commit 1f48e3f into Raynos:master Apr 13, 2023
@@ -10,7 +10,7 @@
],
"author": "Raynos <[email protected]>",
"repository": "git://github.com/Raynos/function-bind.git",
"main": "index",
"main": "index.js",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is actually completely unnecessary, based on node resolution rules.

@ljharb
Copy link
Collaborator

ljharb commented Apr 13, 2023

Specifically, if vite can't handle it, vite is broken - please file an issue on vite.

@svedova
Copy link
Contributor Author

svedova commented Apr 17, 2023

Specifically, if vite can't handle it, vite is broken - please file an issue on vite.

You're right. I think it's the commonjs resolver plugin that cannot handle it, but in any case, I think it doesn't hurt specifying the full file name :)

Thanks for merging the PR!

@svedova svedova deleted the patch-1 branch April 17, 2023 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants