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

Simplify build infrastructure #945

Merged
merged 1 commit into from
Feb 6, 2018
Merged

Simplify build infrastructure #945

merged 1 commit into from
Feb 6, 2018

Conversation

b-admike
Copy link
Contributor

@b-admike b-admike commented Jan 31, 2018

Related to #611

Checklist

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • Related API Documentation was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in packages/example-* were updated

Copy link
Contributor

@shimks shimks left a comment

Choose a reason for hiding this comment

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

Couple of questions

package.json Outdated
@@ -37,7 +37,7 @@
"build": "lerna run build --parallel --loglevel=silent",
"build:current": "lerna run build:current --parallel --loglevel=silent",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there still need for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope, good catch!

@@ -6,7 +6,7 @@
"loopback-<%= project.projectType -%>",
"loopback"
],
"main": "index.js",
"main": "dist/index.js",
"engines": {
"node": ">=8"
},
Copy link
Contributor

Choose a reason for hiding this comment

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

remove dist6 from files (way down; github won't let me comment on unchanged lines)

@@ -38,7 +35,6 @@
"index.js",
"index.d.ts",
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 still need this (and index.js)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope :).

Copy link
Member

Choose a reason for hiding this comment

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

@@ -12,11 +12,12 @@ const spawn = require('cross-spawn');
const debug = require('debug')('loopback:build');

/**
* Get the Node.js compilation target - es2017 or es2015
* Get the Node.js compilation target - es2017
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, we should keep es2015 support for @loopback/build as it can be used to build TypeScript projects independent of LoopBack 4.

Copy link
Member

Choose a reason for hiding this comment

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

+1

Also as I mentioned above, I'd like us to add es2018 target soon (around April this year, when Node.js 10.0.0 is released).

  • V8 6.4 already supports all ES2018 features according to this tweet
  • Node's master branch contains V8 6.4 AFAICT, see deps/v8

Copy link
Member

Choose a reason for hiding this comment

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

(I do realize this contradicts the checklist in #945, which I created back in October last year.)

"index.d.ts",
"dist",
"dist6"
"dist/index.js",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it redundant with dist?

},
"devDependencies": {
"@loopback/build": "^4.0.0-alpha.12",
"@loopback/testlab": "^4.0.0-alpha.22"
},
"files": [
"README.md",
"index.js",
"index.d.ts",
"dist/index.js",
Copy link
Contributor

Choose a reason for hiding this comment

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

Please note we have the following files under dist. We should include all of them except test. The top level index.* files are useful for source map.

index.d.ts
index.js
index.js.map
src
test

Copy link
Contributor

@raymondfeng raymondfeng left a comment

Choose a reason for hiding this comment

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

Please address my comments.

.travis.yml Outdated
@@ -24,8 +27,8 @@ jobs:
before_script: skip
script: /bin/bash ./bin/lint-commits.sh
after_success: skip
node_js:
- "8"
os:
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason why osx is not in the list?

Copy link
Contributor

Choose a reason for hiding this comment

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

Commit message linting only needs to happen once (on any platform) so for this stage we explicitly specify linux. Not specifying any will trigger commit message linting on both platforms which is redundant.

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.

Besides my comments above, I am proposing to split this pull request into two smaller incremental changes:

  1. Drop support for Node.js in engines field, CI config, remove promisify pollyfils. I think this part is pretty non-controversial.

  2. Simplify project infrastructure (package-level index.js files, @loopback/build, etc.) I think these changes require more careful consideration and discussion.

.travis.yml Outdated
- "8"

os:
- linux
- osx
Copy link
Member

Choose a reason for hiding this comment

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

Please don't make two changes in one pull request. Adding osx to our build matrix should be done in a standalone pull request.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The historic reason for this addition is that Travis was only running commit linter instead of our build, since there was no longer a matrix with 1e5bc76. TV and I added it to address that issue. I agree that is a change on its own, so I can create a PR for it.

Copy link
Member

Choose a reason for hiding this comment

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

Wow, I did not realize a single Node.js target would break the matrix build. Thanks for explaining this to me. Your other PR looks good to me. Another option we can consider is to add Node.js 9 to the list of platforms we are testing.

// License text available at https://opensource.org/licenses/MIT

const nodeMajorVersion = +process.versions.node.split('.')[0];
module.exports = nodeMajorVersion >= 7 ? require('./dist') : require('./dist6');
Copy link
Member

Choose a reason for hiding this comment

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

With Node.js 10.0.0 coming in few months, I think we should start planning how to transpile to es2018 target. Since transpiling for both Node.js 8.x and 10.x will require these index files around, I think we should preserve them.

https://twitter.com/jasnell/status/958765477089632257

PSA: Mark your calendars, the expected release date for Node.js 10.0.0 is on or around April 24th. Expect the first As-Close-To-A-Release-Candidate-As-We-Can-Get-It to hit in early April.

Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

(I do realize this contradicts the checklist in #945, which I created back in October last year.)

Copy link
Member

Choose a reason for hiding this comment

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

After thinking about this a bit more: we should leave out transpilation target es2018 out of scope of this pull request.

If we need to keep index.js file around because of #945 (comment), then I am ok with simplifying it to a simple redirect to dist. If it turns out TS+VSCode works well without this hand-written index.js around, then I am ok with deleting it as is proposed here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually yeah we were discussing about es2018 before making this change. I think it might be better to keep them as they do no harm, and if used in the future, we don't have to remake them.

},
"main": "dist/index.js",
Copy link
Member

@bajtos bajtos Feb 1, 2018

Choose a reason for hiding this comment

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

❗️ This is critical ❗️

I think this will break monorepo-wide refactorings in VSCode. Before your change, the TypeScript server was seeing packages/authentication/index.ts and ignoring any .js/.d.ts files produced by our build. With your change in place, the TypeScript server will see packages/authentication/dist/index.js (and index.d.ts), which will hide the original TypeScript sources.

Here are things that will stop working if my assessment is correct:

  • "Go to definition" across packages. How to test: find a place where we are calling @inject in authentication package, press F12 to go to the definition of inject. Right now, VSCode should jump to the .ts file in src. With your changes in place, I believe VSCode will jump to a .d.ts file in dist

  • Refactorings like "rename" will not change all places using the renamed entity. Two different scenarios to verify: rename at the place where the entity is defined, rename at the place where the entity is used. (You can e.g. rename inject to test.)

Please verify whether the three scenarios mentioned above work with your change in place. If they do, then my understanding of TypeScript integration in VSCode is no longer correct and you can ignore my comment.

Copy link
Contributor Author

@b-admike b-admike Feb 1, 2018

Choose a reason for hiding this comment

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

Good catch! The first scenario works, but the other two do not. Would ignoring those files in their new locations fix this issue? (will try and check back)

EDIT: All of those scenarios work fine with these changes in place, but yeah I'm still in favour of preserving our target selector index.js files.

@@ -12,11 +12,12 @@ const spawn = require('cross-spawn');
const debug = require('debug')('loopback:build');

/**
* Get the Node.js compilation target - es2017 or es2015
* Get the Node.js compilation target - es2017
Copy link
Member

Choose a reason for hiding this comment

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

+1

Also as I mentioned above, I'd like us to add es2018 target soon (around April this year, when Node.js 10.0.0 is released).

  • V8 6.4 already supports all ES2018 features according to this tweet
  • Node's master branch contains V8 6.4 AFAICT, see deps/v8

// Add any aditional (re)exports to src/index.ts instead.
export * from './src';

const application = (module.exports = require('./src'));
Copy link
Member

Choose a reason for hiding this comment

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

My two comment above advocating for preservation of package-level index.js file apply to this place too.

@bajtos
Copy link
Member

bajtos commented Feb 1, 2018

Closes #611

@b-admike This phrase is telling GitHub to close #611 automatically after this pull request is landed. Are you sure all other tasks in #611 will be done by that time? In my experience, it's usually better to close user stories manually and avoid using automatic closing via "closes" or "fixes".

@b-admike b-admike mentioned this pull request Feb 1, 2018
6 tasks
@b-admike b-admike changed the title Drop support for Node.js 6 Simplify build infrastructure Feb 1, 2018
@b-admike
Copy link
Contributor Author

b-admike commented Feb 1, 2018

@bajtos Sorry, should not have used closes phrase. There are still outstanding checkboxes in that task that I need to make PRs for in their respective repos. I've put related instead.

@b-admike b-admike force-pushed the build/drop-node6 branch 5 times, most recently from 6955730 to 9868d64 Compare February 2, 2018 16:27
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.

LGTM with one suggestion.

@@ -3,5 +3,6 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

/* eslint-disable no-unused-vars*/
const nodeMajorVersion = +process.versions.node.split('.')[0];
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 remove nodeMajorVersion if it's not used (instead of adding eslit-disable comment).

The same comment applies to all other places below where you added eslint-disable.

(BTW I believe we don't have eslint configured in our monorepo, do you have eslint configured in your IDE independently of our project setup?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, will do. Yeah I have eslint, but realized we use tslint after, and I have that change in the other PRs :).

BREAKING CHANGE: Support for Node.js version lower than 8.0 has been dropped.
Please upgrade to the latest Node.js 8.x LTS version.

Co-Authored-by: Taranveer Virk <[email protected]>
@b-admike b-admike merged commit a2368ce into master Feb 6, 2018
@b-admike b-admike deleted the build/drop-node6 branch February 6, 2018 05:48
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