Skip to content

Conversation

@raymondfeng
Copy link
Contributor

@raymondfeng raymondfeng commented Oct 26, 2017

Description

The PR adds build package to the monorepo. It will be published as @loopback/build. The module exposes a set of build related scripts.

Other modules will use @loopback/build as a dev dependency and use the cli commands for the build.

Related issues

  • connect to <link_to_referenced_issue>

Checklist

  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style
    guide

@raymondfeng raymondfeng requested a review from bajtos as a code owner October 26, 2017 22:49
@raymondfeng raymondfeng changed the title [WIP] feat: Add build scripts as a separate package feat: Add build scripts as a separate package Oct 27, 2017
Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice start!

I am not sure how much value there is in sharing our build scripts that are specific to monorepo structure, but then I don't mind that too much.

In addition to my comments below, please take a look at monorepo-level tslint.* config files, they are still around after your changes:

Most importantly, make sure that the tslint extension for VSCode is picking up the right lint config.

Similarly, there are tsconfig.* files at root level that are used by the VSCode TS intellisense, they must be updated to refer to the shared config from the new build package.

"LoopBack",
"Authentication"
],
"keywords": ["LoopBack", "Authentication"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, we are not (or should not be) applying prettier formatting to package.json, because npm will reformat the file back to JSON.stringify format whenever we change it, typically via npm install. Could you please revert these white-space only changes?

I am not sure if package.json is listed in .prettierignore, feel free to add it there if it isn't. Here is what we did in loopback4-extension-starter (the trick works well with VS Code prettier plugin):

https://github.com/strongloop/loopback4-extension-starter/blob/3a491d40e7d58ad177484de459050ba127215af7/.prettierignore#L4

*.json

@@ -0,0 +1,6 @@
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be using top-level .prettierrc from the monorepo, not per-package configs. Please remove this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional as I want to make sure the scripts are formatted with es5.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, makes sense 👍

@@ -0,0 +1,7 @@
# Lines starting with '#' are comments.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto, CODEOWNERS file does not make sense inside a package. Please move this entry to top-level CODEOWNERS file at monorepo's root level and use a path specifier to limit the codeowners to this package only.

@@ -0,0 +1,6 @@
{
"include": ["packages/example-codehub/src/**", "packages/*/dist*/*"],
"exclude": ["packages/core/*/promisify.*"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This configuration is specific to loopback-next (include packages/example-codehub, exclude promisify.* from core), it does not belong to a shared/common config.

"unit":
"lb-dist mocha --opts ../../test/mocha.opts 'DIST/test/unit/**/*.js'",
"verify":
"npm pack && tar xf loopback-context*.tgz && tree package && npm run clean"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment applies here - please revert whitespace changes, npm is going to revert them anyways.

Please do the same in all package.json files modified by this PR.

@bajtos
Copy link
Member

bajtos commented Oct 27, 2017

The CI build is failing on all platforms (Travis, AppVeyor + Node.js 6.x, 8.x), please check.

"build:dist": "lb-tsc es2017",
"build:dist6": "lb-tsc es2015",
"build:apidocs": "lb-apidocs",
"tslint": "lb-tslint",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cool if the project uses the same tslint config as we do. However, if the project wants to customize their tslint settings, how can they do that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See README

"build:apidocs": "lb-apidocs",
"tslint": "lb-tslint",
"tslint:fix": "npm run tslint -- --fix",
"prettier:cli": "lb-prettier \"**/*.ts\"",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cool if the project uses the same prettier config as we do. However, if the project wants to customize their settings, how can they do that? Could you please explain that in README?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See README

@raymondfeng raymondfeng force-pushed the add-buildlab branch 3 times, most recently from a7e2066 to bfec8ae Compare October 27, 2017 17:03
@raymondfeng
Copy link
Contributor Author

I am not sure how much value there is in sharing our build scripts that are specific to monorepo structure, but then I don't mind that too much.

The @loopback/build is not only for the monorepo. I was motivated to create this package for other repos such as loopback4-extension-grpc and loopback4-extension-starter. Once the PR is merged, I'll create other PRs to switch to @loopback/build for these modules.

@raymondfeng
Copy link
Contributor Author

@bajtos PTAL.

Copy link
Contributor

@b-admike b-admike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this PR is a bit big to review, I don't really have any concerns. I like how the package is composed of many (mainly independent) build scripts so that people can pick and choose what they want out of it.

"packages/*/node_modules/**",
"**/*.d.ts"
]
"extends": "./packages/build/config/tsconfig.common.json",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the following line here as well?

 "$schema": "http://json.schemastore.org/tsconfig"

const path = require('path');
const fs = require('fs');

const utils = require('../../bin/utils');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really use utils in this test case. Can we test its exported functions here as well as the scripts in /bin? You can test them in separate files or describe blocks, but I leave the organization up to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Fixed.

@raymondfeng raymondfeng force-pushed the add-buildlab branch 3 times, most recently from b42e96f to 08fdb9d Compare October 27, 2017 18:55
@@ -0,0 +1,45 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file doesn't need to be moved as we don't expose it in build and loopback-next still seems to be using the one from /bin.

@raymondfeng raymondfeng force-pushed the add-buildlab branch 5 times, most recently from 185a4ab to c6f7599 Compare October 27, 2017 20:26
@raymondfeng raymondfeng force-pushed the add-buildlab branch 2 times, most recently from 78ccf5f to a96a680 Compare October 27, 2017 21:19
@raymondfeng
Copy link
Contributor Author

@bajtos PTAL

Copy link
Contributor

@kjdelisle kjdelisle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm mostly happy about the scripts no longer containing tons of ../../../../../

Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid I don't have enough time to review these changes in all details and I don't want to block progress. The changes LGTM at high level now.

My only concern is about mono-repo's top-level tsconfig.build.json which seems to mostly duplicate the content in packages/build/config/tslint.build.json.

@@ -0,0 +1,6 @@
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, makes sense 👍

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

Successfully merging this pull request may close these issues.

6 participants