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

Compilers should be able to add keys to component's package.json #1762

Closed
itaymendel opened this issue Jun 26, 2019 · 1 comment
Closed

Compilers should be able to add keys to component's package.json #1762

itaymendel opened this issue Jun 26, 2019 · 1 comment
Assignees
Milestone

Comments

@itaymendel
Copy link
Contributor

itaymendel commented Jun 26, 2019

Description

Some compilers modify values in the package.json file. For example, ng-packagr needs to add the following keys:

"module": "...",
"es2015": "...",
"esm5": "...",
"esm2015": "...",
"fesm5": "...",
"fesm2015": "...",
"typings": "...",
"metadata": "..."

Describe the solution you'd like

Bit should provide an API for a compiler to add values to the package.json file.
There are two important things to note:

  1. The compiler should modify the package.json during the build process.
  2. When bit build runs and a compiler causes a modification to the package.json file - The component must not be modified.
  3. There are several keys that a compiler must not be able to modify/create
    • name
    • version
    • main
    • dependencies
    • devDependencies
    • peerDependencies
    • license
    • bit
@GiladShoham GiladShoham added this to the Angular milestone Jun 27, 2019
@davidfirst davidfirst self-assigned this Jun 27, 2019
davidfirst added a commit that referenced this issue Jun 28, 2019
* implement #1762, allow compilers to add properties to the component package.json file

* save the manually changed package.json props into the scope

* disable caching of CircleCI to hopefully fix the strange error "SyntaxError: Unexpected token import" we randomly get

* add validations to make sure the new Version prop "packageJsonChangedProps" is stored correctly and doesn't override core props
@davidfirst
Copy link
Member

Implemented in #1769.
To add properties to the package.json, just add a new property packageJson to the return result.

In the example below, a compiler adds { "foo": "bar" } into the component package.json.

function compile(files, distPath) {
  const dists = files.map(f => doSomethingWhatever(f));
  return { dists, packageJson: { foo: 'bar' } };
}

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