Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.
This repository was archived by the owner on May 1, 2020. It is now read-only.

Local packages and component downloads #6

@Pavel910

Description

@Pavel910

@eahefnawy I'd like to suggest/discuss an alternative way of handling component downloads.

The main problem for me is that Template throws an error if it doesn't find the component package on NPM. However, my component packages are still far from ready for publishing to NPM, and they are located in my monorepo with all the other packages, and are resolvable via node_modules.

I have 2 possible solutions:

  1. when a component is not found on NPM, but can be resolved via require.resolve - just use that and do not throw an error.
  2. add a configuration flag to component, something like this:
api:
  component: '@webiny/microservice'
  registry: false // <-- this would skip all registry checks

I personally prefer the first solution as it does not require any additional code/configuration on developer's side.

Currently the only packages that are not downloaded are the ones starting with ., which is not very useful, as I want to use the component name as a regular npm module, like @webiny/microservice, but it is a local/private package that is not on npm.

Looking forward to hearing your opinion on this! 🍻

EDIT:
Here is the modification required to implement the first solution.

https://github.com/serverless/core/blob/master/src/utils/download.js#L82

let componentVersionToInstall
try {
    componentVersionToInstall = await getComponentVersionToDownload(component)
} catch (e) {
    if (require.resolve(component)) {
        componentsPathsMap[component] = component
        return
    }
    throw e
}

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