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

Adding node shims for a third-party dependency #901

Open
1 of 4 tasks
thektan opened this issue Apr 1, 2022 · 3 comments
Open
1 of 4 tasks

Adding node shims for a third-party dependency #901

thektan opened this issue Apr 1, 2022 · 3 comments

Comments

@thektan
Copy link
Member

thektan commented Apr 1, 2022

Issue type (mark with x)

  • πŸ€” Question
  • πŸ› Bug report
  • 🎁 Feature request
  • πŸ€·β€β™€οΈ Other

Description

I previously created a thread in #t-dxp-frontend-infra here: https://liferay.slack.com/archives/CNBG06JS3/p1648595258944989

I'm trying to add a third-party dependency @apidevtools/json-schema-ref-parser (https://github.com/APIDevTools/json-schema-ref-parser) to traverse a JSON schema for autocompletion in a code editor. The package uses require('http') and require('https'). In portal I get errors of missing dependency:

[
    "Missing dependency 'liferay!search-experiences-web$http' of '@liferay!search-experiences-web$apidevtools/[email protected]/lib/resolvers/http'",
    "Missing dependency 'liferay!search-experiences-web$https' of '@liferay!search-experiences-web$apidevtools/[email protected]/lib/resolvers/http'",
    "Missing version constraints for 'liferay!search-experiences-web$http' in package.json of '@liferay!search-experiences-web$apidevtools/[email protected]' (required from its 'lib/resolvers/http' module)",
    "Missing version constraints for 'liferay!search-experiences-web$https' in package.json of '@liferay!search-experiences-web$apidevtools/[email protected]' (required from its 'lib/resolvers/http' module)"
]

A github issue (APIDevTools/json-schema-ref-parser#254 (comment)) about these missing packages resolves this issue by adding polyfills stream-http and https-browserify using the webpack.config.js configuration:

module.exports = {
  resolve: {
    fallback: {
      https: require.resolve("https-browserify"),
      http: require.resolve("stream-http")
    },

Desired behavior:
Can something similar to the webpack.config.js be done (or supported if it doesn't exist) to resolve the missing dependencies?

Current behavior:
Unable to resolve the missing node http and https dependencies to use the @apidevtools/json-schema-ref-parser package.

@bryceosterhaus
Copy link
Member

Hey @thektan! Thanks for opening this. How urgent is this need? We can fit it in at some point, but just want to get an idea of how soon we need to work on it.

@thektan
Copy link
Member Author

thektan commented Apr 7, 2022

Hi @bryceosterhaus! I was able to write a basic $ref resolver which works for simple paths in the same file. It works for our use case at the moment so this is not as urgently needed anymore.

It'd still be helpful to eventually use this library to resolve references to other files so we could organize and reduce duplicated schema, but I'd say this not as important anymore.

@bryceosterhaus
Copy link
Member

@thektan good to know! Let us know if/when this becomes more urgent. We will keep this in our backlog and hope to address it soon, however we are working on some new build and bundle processes and we may not need node shims in the future, so its possible this may resolve itself with new techniques.

@izaera izaera added the feat label Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants