Raynos / function-bind

MIT License
138 stars 27 forks source link

Point to the correct file #16

Closed svedova closed 1 year ago

svedova commented 1 year ago

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")
    }
  ]
}
svedova commented 1 year ago

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

Raynos commented 1 year ago

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

ljharb commented 1 year ago

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

svedova commented 1 year ago

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!