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: vendor hexoid until v2 is released #978

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

icholy
Copy link

@icholy icholy commented Jul 30, 2024

Problem:

The v1.0.0 release of hexoid is incompatible with webpack.

main.js

require('formidable');

webpack.config.js

module.exports = {
	target: 'node',
	entry: './main.js',
	optimization: {
		minimize: false
	}
}

Output:

/home/icholy/src/playground/hexoid-webpack/dist/main.js:1381
const toHexoId = hexoid(25);
                 ^

TypeError: hexoid is not a function
    at 211 (/home/icholy/src/playground/hexoid-webpack/dist/main.js:1381:18)
    at __webpack_require__ (/home/icholy/src/playground/hexoid-webpack/dist/main.js:2121:41)
    at /home/icholy/src/playground/hexoid-webpack/dist/main.js:2158:1
    at Object.<anonymous> (/home/icholy/src/playground/hexoid-webpack/dist/main.js:2160:12)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    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 Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49

Root Cause:

Webpack prefers the module entry over the main entry in package.json by default, but hexoid exports incompatible APIs between the commonjs & esm modules. The esm module uses a default export which is not equivalent to the module.exports assignment in the commonjs module.

Solution 1:

The hexoid repo has fixed the inconsistency in their master branch, but haven't published a release in 4 years. I've requested a v2 be published with the new exports. Once this happens, we can upgrade to that: lukeed/hexoid#7

Solution 2:

In the meantime, I propose that we vendor the hexoid code as a helper function.

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.

None yet

1 participant