-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
There was a problem hiding this 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", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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" | |||
}, |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #945 (comment)
76b03a4
to
56560e4
Compare
packages/build/bin/utils.js
Outdated
@@ -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 |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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
?
packages/core/package.json
Outdated
}, | ||
"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", |
There was a problem hiding this comment.
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
There was a problem hiding this 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: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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:
-
Drop support for Node.js in
engines
field, CI config, removepromisify
pollyfils. I think this part is pretty non-controversial. -
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
packages/authentication/index.js
Outdated
// License text available at https://opensource.org/licenses/MIT | ||
|
||
const nodeMajorVersion = +process.versions.node.split('.')[0]; | ||
module.exports = nodeMajorVersion >= 7 ? require('./dist') : require('./dist6'); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
packages/authentication/package.json
Outdated
}, | ||
"main": "dist/index.js", |
There was a problem hiding this comment.
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
inauthentication
package, press F12 to go to the definition ofinject
. Right now, VSCode should jump to the.ts
file insrc
. With your changes in place, I believe VSCode will jump to a.d.ts
file indist
-
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.
There was a problem hiding this comment.
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.
packages/build/bin/utils.js
Outdated
@@ -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 |
There was a problem hiding this comment.
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')); |
There was a problem hiding this comment.
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.
@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". |
56560e4
to
18b6265
Compare
@bajtos Sorry, should not have used |
6955730
to
9868d64
Compare
There was a problem hiding this 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.
packages/authentication/index.js
Outdated
@@ -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]; |
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
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 :).
ce1796f
to
a8f0b20
Compare
a8f0b20
to
9f9c9a5
Compare
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]>
9f9c9a5
to
2b4f822
Compare
Related to #611
Checklist
npm test
passes on your machinepackages/cli
were updatedpackages/example-*
were updated