Skip to content

Dynamic require of .json where file extension is not provided #79

@eerichmond

Description

@eerichmond

Hi,
I'm trying to use ncc with the npm module "conventional-changelog-core" from the project https://github.com/conventional-changelog/conventional-changelog and found that the ncc_wildcards function does not seem to work if the arg passed in is missing the file extension (eg ".json"). It looks like the method generateWildcardRequire in "src/asset-relocator.js" is not recognizing that the arg coming in is extension-less. The offending file is https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog-core/lib/merge-config.js#L222 where it is calling require('../hosts/' + type). In this scenario "type" is either "github", "bitbucket" or "gitlab" but the actual file it is trying to pull in is "../hosts/github.json", "../hosts/bitbucket.json" or "../hosts/gitlab.json". The resulting ncc_wildcard function looks like

function __ncc_wildcard$0 (arg) {
  if (arg === "bitbucket.json") return __webpack_require__(749);
  else if (arg === "github.json") return __webpack_require__(520);
  else if (arg === "gitlab.json") return __webpack_require__(404);
}

but the actual function is called like this:

hostOpts = __ncc_wildcard$0(type)

where "type" is "github", "bitbucket" or "gitlab".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions