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

refactor(stark-all): replace 'lodash' by tree-shakeable 'lodash-es'. Add '@types/lodash-es' to get correct typings. #1147

Merged

Conversation

carlo-nomes
Copy link
Collaborator

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[x] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: #150

What is the new behavior?

Lodash-es imports and typings

Does this PR introduce a breaking change?

[x] Yes
[ ] No

Other information

@carlo-nomes carlo-nomes force-pushed the feature/lodash-types branch 4 times, most recently from 894bdaf to 44b2475 Compare February 26, 2019 08:19
@coveralls
Copy link

coveralls commented Feb 26, 2019

Coverage Status

Coverage decreased (-2.0%) to 92.725% when pulling 3a8a21b on cnomes:feature/lodash-types into 517df61 on NationalBankBelgium:master.

Copy link
Collaborator

@christophercr christophercr left a comment

Choose a reason for hiding this comment

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

Small remarks

...defaultKarmaConfig.karmaTypescriptConfig,
bundlerOptions: {
...defaultKarmaConfig.karmaTypescriptConfig.bundlerOptions,
transforms: [
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add these to the exports of this file so that you can access it in stark-core/karma.conf.ci.js instead of duplicating this block in these 2 files?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was thinking of doing this with #1145 (amongst other things). But I could append a commit to this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Mmm well I don't think that this will change that much when #1145 is solved right? We would need to apply the same logic here... so we could re-use it here instead of duplicating it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was thinking of writing (using) a merge function so that a single config file could be exported from the karma.conf.js

packages/stark-ui/karma.conf.js Outdated Show resolved Hide resolved
@@ -28,6 +28,7 @@
"dependencies": {
"@angular/material-moment-adapter": "^7.0.0",
"@mdi/angular-material": "^3.3.92",
"@types/lodash-es": "^4.17.1",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't the types from lodash-es be taken from stark-core by changing the path in the tsconfig.json of stark-ui ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will try again, but I think my IDE didn't recognize the types when I tried that. 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm hitting a lot of other issues. Maybe this is more suitable for a separate ticket? 😕

showcase/package.json Outdated Show resolved Hide resolved
starter/package.json Outdated Show resolved Hide resolved
starter/package-lock.json Outdated Show resolved Hide resolved
starter/package-lock.json Outdated Show resolved Hide resolved
starter/package-lock.json Outdated Show resolved Hide resolved
starter/package-lock.json Outdated Show resolved Hide resolved
packages/stark-ui/karma.conf.js Show resolved Hide resolved
@christophercr christophercr added this to the 10.0.0-beta.5 milestone Feb 26, 2019
@christophercr christophercr added type: enhancement comp: stark-all To apply for all Stark modules labels Feb 26, 2019
@christophercr christophercr changed the title Feature/lodash types refactor(stark-all): replace 'lodash' by tree-shakeable 'lodash-es'. Add '@types/lodash-es' to get correct typings. Feb 26, 2019
@carlo-nomes carlo-nomes force-pushed the feature/lodash-types branch 7 times, most recently from b88f813 to 0d3d8e0 Compare February 28, 2019 13:40
@carlo-nomes carlo-nomes force-pushed the feature/lodash-types branch from 0d3d8e0 to 6e26513 Compare March 4, 2019 14:13
@carlo-nomes carlo-nomes force-pushed the feature/lodash-types branch 2 times, most recently from edbad62 to 2a5a870 Compare March 21, 2019 16:44
@carlo-nomes
Copy link
Collaborator Author

The build works, so this Pr is ready for some extra reviewing. 😄

Copy link
Collaborator

@christophercr christophercr left a comment

Choose a reason for hiding this comment

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

Just small remarks... the rest looks good 👍

packages/stark-testing/karma.conf.ci.js Outdated Show resolved Hide resolved
packages/stark-testing/karma.conf.js Outdated Show resolved Hide resolved
packages/stark-testing/karma.conf.ci.js Outdated Show resolved Hide resolved
packages/stark-testing/karma.conf.js Outdated Show resolved Hide resolved
packages/stark-testing/karma.conf.ci.js Outdated Show resolved Hide resolved
packages/stark-testing/karma.conf.js Outdated Show resolved Hide resolved
packages/stark-ui/tsconfig-build.json Outdated Show resolved Hide resolved
packages/stark-build/config/tslint.json Show resolved Hide resolved
@christophercr
Copy link
Collaborator

Also these files need to be changed (they are still using lodash instead of lodash-es):

  • packages/stark-core/src/modules/http/services/http.service.ts
  • packages/stark-core/src/util/http.util.ts
  • packages/stark-ui/src/modules/date-picker/components/date-picker.component.ts
  • showcase/src/app/demo-ui/pages/generic-search/components/demo-generic-search-form.component.ts
  • showcase/src/app/demo-ui/pages/message-pane/demo-message-pane-page.component.ts
  • showcase/src/assets/examples/message-pane/message-pane.ts

@carlo-nomes carlo-nomes force-pushed the feature/lodash-types branch 3 times, most recently from b4a5071 to f8ab02c Compare March 27, 2019 15:06
  - added used modules to rollup globals (TODO: NationalBankBelgium#1129)
  - blacklisted `lodash-es` (use submodules instead)
  - added `karma-typescript-es6-transform` for transforming es6 dependencies
    - added workaround for monounity/karma-typescript#320 in `base.spec.ts` (stark-core, stark-ui, showcase, starter)
    - aliased all used lodash modules in karma.conf.js (TODO NationalBankBelgium#1145)
  - minor refactors

ISSUES CLOSED: NationalBankBelgium#150
This commit will refactor all used instances of `const (.*) = require("lodash/(.*)")` to `import (.*) from "lodash/(.*)"`

ISSUES CLOSED: NationalBankBelgium#150
@carlo-nomes carlo-nomes force-pushed the feature/lodash-types branch from f8ab02c to 1ff90ff Compare March 27, 2019 15:17
@carlo-nomes carlo-nomes force-pushed the feature/lodash-types branch from 1ff90ff to 3a8a21b Compare March 27, 2019 15:21
@christophercr
Copy link
Collaborator

LGTM 👍

@SuperITMan can you have a look on this PR?

@christophercr christophercr removed the request for review from Mallikki March 28, 2019 11:08
@SuperITMan SuperITMan merged commit c5c34c6 into NationalBankBelgium:master Apr 1, 2019
christophercr added a commit to christophercr/stark that referenced this pull request Apr 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp: stark-all To apply for all Stark modules type: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants