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
build: apply Angular package format and ng-packagr
#167
Conversation
@@ -15,7 +15,7 @@ const defaultOpts = { | |||
updateFunction: () => Promise.resolve(), | |||
}; | |||
|
|||
export default function singleSpaAngular(userOpts: SingleSpaAngularOpts): LifeCycles { | |||
export function singleSpaAngular(userOpts: SingleSpaAngularOpts): LifeCycles { |
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.
@4
because angular's package format and ng-packagr don't allow default exports.
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.
:'( that sucks
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.
Thanks for your work on this. I honestly don't understand everything here, since I don't really know Angular schematics, ngpackagr, or really much about Angular at all :)
My biggest question is why we have multiple package.json's now - it seems like the root package.json is set up monorepo style, but then it has all of the dependencies and build scripts which is not how monorepos work. Why does only the browser lib have its own package.json instead of also the schematics and webpack libs?
"description": "Helpers for building single-spa applications which use Angular 2", | ||
"main": "lib/browser-lib/single-spa-angular.js", | ||
"schematics": "./schematics.json", | ||
"version": "0.0.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.
Is this now 0.0.0 because the repo has been converted to a monorepo with multiple package.jsons?
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.
https://github.com/ng-packagr/ng-packagr/blob/master/docs/DESIGN.md#folder-layout
Not monorepo. Basically the root package.json we use for such stuff as scripts, dependencies and husky/prettier.
There is another package.json
inside the src
folder that is taken by ng-packagr. ng-packagr automatically adds webpack fields like main/module/es2015/esm5
and typings
field.
"clean": "rimraf lib parcel", | ||
"test": "jest", | ||
"clean": "rimraf lib pacel", | ||
"build": "run-s clean build:single-spa-angular build:webpack build:schematics", |
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 these all need to be sequential? Couldn't all the builds occur after the clean?
"build": "run-s clean build:single-spa-angular build:webpack build:schematics", | |
"build": "yarn clean && concurrently -n w: 'yarn:build:*'", |
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.
Umm, yes. Basically build:single-spa-angular
should be first, because it will create lib
folder. Other scripts can be parallel.
@@ -15,7 +15,7 @@ const defaultOpts = { | |||
updateFunction: () => Promise.resolve(), | |||
}; | |||
|
|||
export default function singleSpaAngular(userOpts: SingleSpaAngularOpts): LifeCycles { | |||
export function singleSpaAngular(userOpts: SingleSpaAngularOpts): LifeCycles { |
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.
:'( that sucks
"format": "prettier './**/*' --write", | ||
"// - INTEGRATION INSTALLS": "Install packages for integration apps", | ||
"install:integration:shop": "yarn --cwd integration/shop install", | ||
"install:integration:portal": "yarn --cwd integration/portal install", | ||
"install:integration": "yarn install:integration:shop && yarn install:integration:portal", | ||
"install:integration": "run-s install:integration:shop install:integration:portal", |
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.
Why sequential? Couldn't they run concurrently?
"install:integration": "run-s install:integration:shop install:integration:portal", | |
"install:integration": "concurrently -n w: 'yarn:install:integration:*'", |
"// - SINGLE-SPA-ANGULAR": "Scripts for building single-spa-angular", | ||
"build:single-spa-angular": "yarn ts-node tools/build", | ||
"// - WEBPACK": "Scripts for building Webpack config transformer", | ||
"prebuild:webpack": "rimraf lib/lib", |
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.
Why is there a lib/lib directory?
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.
webpack is emitted there
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.
Why then is the import for webpack at single-spa-angular/lib/webpack
instead of single-spa-angular/lib/lib/webpack
?
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 question is the main one I'm waiting on before reviewing again to approve/merge ^
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 content of the lib folder is copied into node_modules/single-spa-angular folder
"prettier": "^2.0.4", | ||
"rimraf": "^2.6.2", | ||
"rxjs": "~6.5.5", | ||
"serve": "^11.3.0", | ||
"start-server-and-test": "^1.10.11", | ||
"ts-jest": "^24.0.0", | ||
"tsickle": "^0.38.1", |
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.
Why is this needed?
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.
it's a part of ng-packagr, it adds jsdoc annotations for the closure compiler.
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.
If it's part of ng-packagr, then why do we need to install it separately from ng-packagr?
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.
Because it's not a peer dependency of ng-packagr, but it does require that package (I wasn't the author of such solution 🙂 )
@joeldenning I would like you to pull changes and test them locally. That would be great since I don't wanna introduce any breaking changes. You can see something that I don't see :D |
I'll take a look tomorrow |
I didn't get to this today. Will try for tomorrow. Today, tomorrow, and Thursday I am doing full-time consulting with a company. I recently quit my job to try to take my work on open source full time, and do consulting a few days a month to help pay the bills. This week happens to be the week where I'm doing that consulting. So I'll try to fit it in in the next couple days, but if not then I will definitely take a look at this by Friday |
I am looking at this now. Have a few questions that I'll share in a PR with a few small changes. If you're available and have time to chat over Slack, let's talk in the single-spa slack workspace. |
@joeldenning I'm having a Friday release. I will be available tomorrow. |
👍 sounds good - I will send a PR up with some small changes and also have a list of questions in it. |
No description provided.