Skip to content

Commit

Permalink
feat(build): add lodash es imports and lodash types
Browse files Browse the repository at this point in the history
  - 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
  • Loading branch information
carlo-nomes committed Feb 27, 2019
1 parent 9f39370 commit ec4cc3d
Show file tree
Hide file tree
Showing 28 changed files with 9,619 additions and 6,371 deletions.
10 changes: 10 additions & 0 deletions packages/rollup.config.common-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ const globals = {
cerialize: "cerialize",
ibantools: "ibantools",
moment: "moment",
"lodash-es/cloneDeep": "lodash-es.cloneDeep",
"lodash-es/findIndex": "lodash-es.findIndex",
"lodash-es/floor": "lodash-es.floor",
"lodash-es/get": "lodash-es.get",
"lodash-es/isEmpty": "lodash-es.isEmpty",
"lodash-es/isEqual": "lodash-es.isEqual",
"lodash-es/merge": "lodash-es.merge",
"lodash-es/noop": "lodash-es.noop",
"lodash-es/sortBy": "lodash-es.sortBy",
"lodash-es/uniqueId": "lodash-es.uniqueId",
nouislider: "nouislider",
"prettier/standalone": "prettier.standalone",
"prettier/parser-babylon": "prettier.parserBabylon",
Expand Down
2 changes: 1 addition & 1 deletion packages/stark-build/config/tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
}
],
"no-magic-numbers": false,
"import-blacklist": [true, "@angular/material", "lodash", "rxjs/internal", "rxjs/index", "rxjs/Rx"],
"import-blacklist": [true, "@angular/material", "lodash", "rxjs/internal", "rxjs/index", "rxjs/Rx", "lodash-es"],
"ordered-imports": false,
"max-classes-per-file": false, // [true, 1],
"prefer-for-of": true,
Expand Down
41 changes: 30 additions & 11 deletions packages/stark-build/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/stark-core/base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import "core-js/es7/reflect";
import "core-js/stage/4";

/* tslint:disable:no-import-side-effect */
// FIXME: change when https://github.com/monounity/karma-typescript/issues/320 is resolved
// tslint:disable-next-line:import-blacklist
import "lodash-es"; // see https://github.com/monounity/karma-typescript/issues/150#issuecomment-318620280
import "zone.js/dist/zone";
import "zone.js/dist/long-stack-trace-zone";
import "zone.js/dist/proxy"; // since zone.js 0.6.15
Expand Down
15 changes: 14 additions & 1 deletion packages/stark-core/karma.conf.ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,20 @@ const starkCoreSpecificConfiguration = Object.assign({}, defaultKarmaCIConfig, {
dir: helpers.root("reports/coverage/packages")
}),
// add missing files due to "@nationalbankbelgium/stark-core" imports used in mock files of the testing sub-package
files: [...defaultKarmaCIConfig.files, ...karmaTypescriptFiles]
files: [...defaultKarmaCIConfig.files, ...karmaTypescriptFiles],
// Overwrite the karmaTypescriptConfig to pass the correct preset to karma-typescript-es6-transform
karmaTypescriptConfig: {
...defaultKarmaCIConfig.karmaTypescriptConfig,
bundlerOptions: {
...defaultKarmaCIConfig.karmaTypescriptConfig.bundlerOptions,
transforms: [
require("@nationalbankbelgium/stark-testing/node_modules/karma-typescript-angular2-transform"),
require("@nationalbankbelgium/stark-testing/node_modules/karma-typescript-es6-transform")({
presets: ["@nationalbankbelgium/stark-testing/node_modules/babel-preset-env"]
}) // add preset in a way that stark-core can find it
]
}
}
});

// export the configuration function that karma expects and simply return the stark configuration
Expand Down
15 changes: 14 additions & 1 deletion packages/stark-core/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,20 @@ const karmaTypescriptFiles = [{ pattern: helpers.root("index.ts") }, { pattern:
// start customizing the Karma configuration from stark-testing
const starkCoreSpecificConfiguration = Object.assign({}, defaultKarmaConfig, {
// add missing files due to "@nationalbankbelgium/stark-core" imports used in mock files of the testing sub-package
files: [...defaultKarmaConfig.files, ...karmaTypescriptFiles]
files: [...defaultKarmaConfig.files, ...karmaTypescriptFiles],
// Overwrite the karmaTypescriptConfig to pass the correct preset to karma-typescript-es6-transform
karmaTypescriptConfig: {
...defaultKarmaConfig.karmaTypescriptConfig,
bundlerOptions: {
...defaultKarmaConfig.karmaTypescriptConfig.bundlerOptions,
transforms: [
require("@nationalbankbelgium/stark-testing/node_modules/karma-typescript-angular2-transform"),
require("@nationalbankbelgium/stark-testing/node_modules/karma-typescript-es6-transform")({
presets: ["@nationalbankbelgium/stark-testing/node_modules/babel-preset-env"]
}) // add preset in a way that stark-core can find it
]
}
}
});

// export the configuration function that karma expects and simply return the stark configuration
Expand Down
Loading

0 comments on commit ec4cc3d

Please sign in to comment.