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

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

Open
eerichmond opened this issue Feb 13, 2020 · 0 comments
Open

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

eerichmond opened this issue Feb 13, 2020 · 0 comments

Comments

@eerichmond
Copy link

eerichmond commented Feb 13, 2020

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".

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

No branches or pull requests

1 participant