Skip to content

Adding node shims for a third-party dependencyΒ #901

Open
@thektan

Description

@thektan

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/json-schema-ref-parser@9.0.9/lib/resolvers/http'",
    "Missing dependency 'liferay!search-experiences-web$https' of '@liferay!search-experiences-web$apidevtools/json-schema-ref-parser@9.0.9/lib/resolvers/http'",
    "Missing version constraints for 'liferay!search-experiences-web$http' in package.json of '@liferay!search-experiences-web$apidevtools/json-schema-ref-parser@9.0.9' (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/json-schema-ref-parser@9.0.9' (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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions