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

build: apply Angular package format and ng-packagr #167

Merged
merged 4 commits into from Apr 13, 2020
Merged

build: apply Angular package format and ng-packagr #167

merged 4 commits into from Apr 13, 2020

Conversation

arturovt
Copy link
Collaborator

No description provided.

@@ -15,7 +15,7 @@ const defaultOpts = {
updateFunction: () => Promise.resolve(),
};

export default function singleSpaAngular(userOpts: SingleSpaAngularOpts): LifeCycles {
export function singleSpaAngular(userOpts: SingleSpaAngularOpts): LifeCycles {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

⚠️ breaking change for @4 because angular's package format and ng-packagr don't allow default exports.

Copy link
Member

Choose a reason for hiding this comment

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

:'( that sucks

@arturovt arturovt marked this pull request as ready for review April 12, 2020 12:56
Copy link
Member

@joeldenning joeldenning left a 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",
Copy link
Member

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?

Copy link
Collaborator Author

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",
Copy link
Member

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?

Suggested change
"build": "run-s clean build:single-spa-angular build:webpack build:schematics",
"build": "yarn clean && concurrently -n w: 'yarn:build:*'",

Copy link
Collaborator Author

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 {
Copy link
Member

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",
Copy link
Member

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?

Suggested change
"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",
Copy link
Member

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

webpack is emitted there

Copy link
Member

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?

https://github.com/single-spa/single-spa-angular/pull/167/files#diff-def93996c46300cb52885ed7c3584275R1

Copy link
Member

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 ^

Copy link
Collaborator Author

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",
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Collaborator Author

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.

Copy link
Member

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?

Copy link
Collaborator Author

@arturovt arturovt Apr 13, 2020

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 joeldenning merged commit 6a7d487 into single-spa:master Apr 13, 2020
@arturovt arturovt deleted the ng-packagr branch April 13, 2020 21:13
@arturovt
Copy link
Collaborator Author

arturovt commented Apr 13, 2020

@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

@joeldenning
Copy link
Member

I'll take a look tomorrow

@joeldenning
Copy link
Member

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

@joeldenning
Copy link
Member

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.

@arturovt
Copy link
Collaborator Author

@joeldenning I'm having a Friday release. I will be available tomorrow.

@joeldenning
Copy link
Member

👍 sounds good - I will send a PR up with some small changes and also have a list of questions in it.

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.

None yet

2 participants