Skip to content

Conversation

@vojtechszocs
Copy link
Contributor

This PR fixes a problem with Lodash module replacement during webpack build.

The standard Lodash import style used in Console is

import * as _ from 'lodash';
import * as _ from 'lodash-es'; // should go away as part of #1724

with both _ objects having an equivalent structure.

Problem 1, is structural difference between lodash/foo vs. lodash-es/foo imports

var memoize = require('lodash/memoize');    // memoize is function
var memoize = require('lodash-es/memoize'); // memoize is Module => memoize.default is function

Problem 2, is the weird-looking lodash.foo form used by some vendor libraries

var cloneDeep = require('lodash.clonedeep');    // cloneDeep is function
var cloneDeep = require('lodash-es.clonedeep'); // error, no such module available

Therefore, the replacement RegExp is changed to /^lodash$/.

This also means that parts of lodash (technically a separate library) will make it into webpack-generated chunks, due to vendor libraries using either lodash/foo or lodash.foo. I don't think we can do anything about this.

Note: from webpack compilation perspective, using

import * as _ from 'lodash-es';

in source code vs. using

import * as _ from 'lodash';

in source code together with /^lodash$/ => lodash-es replacement should yield the same results.

/cc @spadgett @mareklibra

@openshift-ci-robot
Copy link
Contributor

@vojtechszocs: GitHub didn't allow me to request PR reviews from the following users: mareklibra.

Note that only openshift members and repo collaborators can review this PR, and authors cannot review their own PRs.

Details

In response to this:

This PR fixes a problem with Lodash module replacement during webpack build.

The standard Lodash import style used in Console is

import * as _ from 'lodash';
import * as _ from 'lodash-es'; // should go away as part of #1724

with both _ objects having an equivalent structure.

Problem 1, is structural difference between lodash/foo vs. lodash-es/foo imports

var memoize = require('lodash/memoize');    // memoize is function
var memoize = require('lodash-es/memoize'); // memoize is Module => memoize.default is function

Problem 2, is the weird-looking lodash.foo form used by some vendor libraries

var cloneDeep = require('lodash.clonedeep');    // cloneDeep is function
var cloneDeep = require('lodash-es.clonedeep'); // error, no such module available

Therefore, the replacement RegExp is changed to /^lodash$/.

This also means that parts of lodash (technically a separate library) will make it into webpack-generated chunks, due to vendor libraries using either lodash/foo or lodash.foo. I don't think we can do anything about this.

Note: from webpack compilation perspective, using

import * as _ from 'lodash-es';

in source code vs. using

import * as _ from 'lodash';

in source code together with /^lodash$/ => lodash-es replacement should yield the same results.

/cc @spadgett @mareklibra

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jun 19, 2019
@spadgett
Copy link
Member

/retest

Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 19, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: spadgett, vojtechszocs

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 19, 2019
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

5 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@spadgett
Copy link
Member

/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 20, 2019
@spadgett
Copy link
Member

Holding to keep the bot from retesting until the previous test namespace is deleted

@spadgett spadgett added this to the v4.2 milestone Jun 20, 2019
@spadgett
Copy link
Member

/retest

@spadgett
Copy link
Member

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 20, 2019
@openshift-merge-robot openshift-merge-robot merged commit 11660d9 into openshift:master Jun 20, 2019
@logonoff logonoff deleted the fix-lodash-replacement branch September 25, 2025 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants