28 Commits

Author SHA1 Message Date
Anton Gilgur
4f93c443ef
refactor(cache): makeName -> createHash for clarity (#355)
* refactor(cache): makeName -> createHash for clarity

- I've actually been confused multiple times as to what `makeName` does when I read through the cache
  - I re-read the code and then am like "oh it's the hash"...
  - so thought renaming it to `createHash` would make things **a lot** clearer
    - `Name` -> `Hash`
    - `make` -> `create` because that's the more common terminology in programming

- also rename variables that reference `makeName`'s return from `name` to `hash`
  - for the same reason around clarity -- this way it's quicker to interpret whenever you see it too
  - not to mention, `name` can be confusing since we also have `id`, which is a path that is very similar to a name too
    - and lots of `fileName`s too
    - so good to disambiguate/differentiate a bit

* rename object-hash default import so no shadowed variables
2022-06-14 08:35:09 -06:00
Anton Gilgur
a3c26998a4
docs(cache): add/change some comments for clarity (#357)
- use typedoc for `isDirty` comment so that it actually appears in IDEs etc
  - and use `@returns` typedoc annotation for better specification
  - modify the comment a little for better grammar: 3 "or"s and no commas -> 1 "or" and commas
  - use more accurate terminology: "global types" -> "ambient types"
    - that's also more consistent in this codebase itself, where there's a legit function named `checkAmbientTypes`

- in `init`, specify that the `RollingCache` error should never actually happen
  - I was a bit confused by when this would happen, then checked the constructor, and the answer is basically never: it's an invariant / redundant error-check
  - also add a new line for style consistency
2022-06-14 08:32:31 -06:00
Anton Gilgur
b08f272efb
refactor: sort all top-level imports (#337)
- basically, general format is:
  ```ts
  import x from "external-dep"

  import y from "./internal-dep"
  ```
  - so external deps, new line, then internal/local deps
  - with some further sorting within there, like trying to keep Node
    built-ins (e.g. `path`) at the top half of externals, then core deps
    like `typescript`, then any other external deps
    - and similar for internal deps -- core internals at the top half of
      internals, then any other internal deps
    - just to keep things consistent between files -- makes the top
      easier to read through when it's similar between files
    - also makes it easier for contributors to understand where to put
      imports, as there's a sorting already there

- this is how I generally sort my imports and how I wrote most of the
  unit test suite's imports as well

- there is automation for this that we should probably add once TSLint
  is replaced here; some previous art:
  - https://github.com/trivago/prettier-plugin-sort-imports
  - https://github.com/lydell/eslint-plugin-simple-import-sort/
  - Older:
    - https://github.com/renke/import-sort/tree/master/packages/import-sort-style-module
    - https://github.com/mcdougal/js-isort
    - inspired by Python's `isort` ofc
2022-06-01 14:40:54 -06:00
ezolenko
43108732df - fix for wrong this
#333
2022-05-31 20:54:36 -06:00
Anton Gilgur
01272d3ebe
refactor: invert some conditionals for better readability (#335)
- a few `if (cond) { big block } return` could be inverted to
  `if (!cond) return` then the block unindented instead
  - generally speaking, this makes it a lot more readable (less
    indentation, etc) and follows the existing code style in much of the
    codebase, where it's a few quick one-line ifs and then just the rest
    of the code

- shorten the resolvedFileName conditional by using optional chaining
  - prefer the simpler `x?.y` over the older `x && x.y` syntax
- add a `resolved` variable for less repetition of the whole statement
- add a comment to the `pathNormalize` line about why it's used in that
  one place and link to the longer description in the PR as well

- shorten comment about `useTsconfigDeclarationDir` so it doesn't take
  up so much space or look so important as a result
  - and it's easier to read this way and I made the explanation less
    verbose and quicker to read too
- remove the `else` there and just add an early return instead, similar
  to the inverted conditionals above
  - similarly makes it less unindented, more readable etc
2022-05-31 20:42:36 -06:00
Anton Gilgur
197061bf92
refactor: prefer native methods to lodash where possible (#328)
- _.endsWith -> String.endsWith

- _.concat -> Array.concat
- _.each -> Array.forEach
- _.filter -> Array.filter
- _.map -> Array.map
- _.some -> Array.some

- _.has -> `key in Object`
- _.defaults -> Object.assign
- _.get -> `?.` and `??` (optional chaining and nullish coalescing)

- refactor: replace fairly complicated `expandIncludeWithDirs` func to
  just use a few simple `forEach`s
  - not as FP anymore, more imperative, but much simpler to read IMO
- refactor: add a `getDiagnostics` helper to DRY up some code
  - also aids readability IMO

- a few places are still using lodash, but this paves the way toward
  removing it or replacing it with much smaller individual deps
  - _.compact still used because Array.filter heavily complicates the
    type-checking currently
  - _.isFunction still used because while it's a one-liner natively,
    need to import a function in several places
    - also the package `lodash.isFunction` is lodash v3 and quite
      different from the v4 implementation, so couldn't replace with it
      unfortunately
  - _.merge is a deep merge, so there's no native version of this
    - but we may remove deep merges entirely in the future (as tsconfig
      doesn't quite perform a deep merge), or could replace this with a
      smaller `lodash.merge` package or similar

- see also https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore
2022-05-16 16:30:48 -06:00
Eugene Zolenko
2d33064031 - adding all imports to rollup watch #147, #7 2019-03-25 16:25:03 -06:00
Eugene Zolenko
6b0225a7de - redoing switch to generateBundle (#126 #127 #128)
- using rollup's own types
- min rollup bumped to 0.68
- updating dependencies
- package version 0.19
2019-01-04 15:52:31 -07:00
Eugene Zolenko
ad9d16cf1a - fixing lint errors 2018-08-24 12:16:50 -06:00
Eugene Zolenko
4e3a14f466 - saner cache cleaning, not hashing configs if cache is not used 2018-08-24 12:11:33 -06:00
Eugene Zolenko
3b46e8d599 - object-hash hack optional #105 2018-08-14 11:01:28 -06:00
Eugene Zolenko
4d7552206f - workaround for object hash not supporting async/await 2018-08-14 10:35:33 -06:00
Eugene Zolenko
707c6fc300 - fixes for tslint 2018-06-26 10:54:15 -06:00
Eugene Zolenko
84f27fcdb8 - fix for #93 2018-06-25 11:00:01 -06:00
Eugene Zolenko
f15cb84dcc - "clean: true" will not create cache in the first place #68 2018-03-29 18:24:49 -06:00
Eugene Zolenko
a0b835d51a - fix for sourcemaps taken from cache 2018-03-28 10:38:02 -06:00
Eugene Zolenko
4e824739eb - ignoring broken cache #13 2018-02-08 11:15:26 -07:00
ezolenko
f57f8e7fb9 - updating dependencies 2018-02-01 20:57:19 -07:00
Eugene Zolenko
e26cb55dd9 - error output follows tsconfig pretty option #47 2017-12-15 18:02:25 -07:00
ezolenko
448913d411 - fix for #24. forcing declarations for project files even if they are ignored by rollup 2017-08-15 17:56:29 -06:00
ezolenko
81228203cf - option for overriding typescript version for #27 2017-08-11 00:33:36 -06:00
wessberg
29eae41e26 Refactoring. Declarations will now be local to the rollup destination directory 2017-07-27 04:22:49 +02:00
wessberg
919f72ba51 Declarations will now be placed within the 'dest' folder and shadow the filename of the bundle 2017-07-27 02:23:48 +02:00
ezolenko
a102e115f1 - fix for #22 2017-06-28 19:02:26 -06:00
Bryan Ross
b948b49d75 write out DTS file structure 2017-05-29 11:50:31 -06:00
Eugene Zolenko
b471b987fa - using active rollup config as part of cache hash
Partial solution for #15 and a number of other potential conflicts.
2017-04-20 15:14:01 -06:00
ezolenko
722cb2da00 - error codes and types 2017-03-24 23:08:10 -06:00
Eugene Zolenko
96b284635f Watch (#8)
* - partial fix for watch mode (#6)

* - trying to detect watch mode

* - support for watch mode
2017-03-14 19:04:59 -06:00