benjycui / benjycui/omit.js

Acts weird when using with webpack

Open
#10 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
178
Forks
48
PR merge metrics
No merged PRs in 30d

Description

When bundling with webpack.
```js
// import omit from 'omit.js'; <== works
// const omit = require('omit.js').default; <== works
// const omit = require('omit.js'); <== does NOT work
console.log(omit({ foo: 'foo', bar: 'bar' }, ['bar']));
```
May just want to better support commonjs - if a library uses this package internally and requires it via require('omit.js') - and then webpack is used to bundle the lib omit will always be undefined.

I ran into this issue when trying to bundle [cabin](https://github.com/cabinjs/axe) with webpack and omit would always be undefined. The author switched to lodash/omit to remedy the issue.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the webpack bundle behavior from the CommonJS examples in the issue, comparing require('omit.js') with require('omit.js').default and the ES module import. Inspect the omit.js package entry points and bundler configuration, then verify that the direct CommonJS require exposes the omit function when bundled with webpack.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, webpack
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.