378 Commits

Author SHA1 Message Date
Anton Gilgur
327574e843
optim(ci): use npm ci for install and cache npm (#323)
- `npm ci` is installation for, well, CI, and is a good bit faster
  - c.f. https://docs.npmjs.com/cli/v8/commands/npm-ci

- cache `npm` installation with `setup-node` for speedier installs
  - upgrade `setup-node` as this was released in v2.2.0:
    https://github.com/actions/setup-node/releases/tag/v2.2.0
2022-05-10 17:20:34 -06:00
Anton Gilgur
7af216b463
clean: remove partial.ts as this is built into TS (#322)
- at least as of TS 2.1: https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype
  - we have a peerDep on TS >=2.4, so should definitely be compatible
  - and TS is on ~4.6 at this point, so that's _really_ old

- remove the file and the declarations and declaration maps
  - don't rebuild as that's usually done as a separate commit
2022-05-10 17:15:55 -06:00
Anton Gilgur
56716def97
test: add initial unit test suite (#321)
* some unit tests

modifications made by agilgur5 to brekk's original commit:
- rebase with `master` that is 3 years newer
  - fix conflicts with newer code, esp the `tsModule`/`tsProxy` changes
    in this commit
- move `jest` config to the bottom and don't reformat `package.json`
  with tabs

* more

modifications made by agilgur5 to brekk's original commit:
- fix merge conflicts with code that is 3 years newer

* fix tests for windows

* flip that test

* deps: upgrade Jest to v28

- and ts-jest to v28
- @types/jest doesn't have a v28 yet

- look ma, no more vulns!

* refactor: split jest config to jest.config.js

- and add JSDoc typings to it
  - per https://jestjs.io/docs/configuration

* clean: remove redundant jest config

- most of these options are either unused (like `modulePaths` etc) or
  covered by Jest's defaults (`moduleFileExtensions`, `testMatch`, etc)

- also use `ts-jest` preset per its docs and migration docs
  - https://kulshekhar.github.io/ts-jest/docs/migration

* refactor: move tests into __tests__ dir

- per ezolenko's request, though I also prefer to separate them

- fix all relative imports to use `../src/` now

formatting changes:
- improve ordering of imports in tests -- externals first, newline, then
  internal imports
  - do this **consistently**
- consistently put spaces around braces in destructured imports
  - really need better linting (and update to ESLint)
- consistently add newline after imports and before declarations

- in general, add more newlines for readability in several files

* deps: import from @jest/globals instead of using globals

- no config needed and uses standard imports too
  - also required for future Jest ESM support I believe
  - I created the `jest-without-globals` package before this feature was
    released in Jest core and contributed a PR for it too, so might have
    a bias toward not using globals

* fix(test): update get-options-overrides spec to match latest file

- basically to match the changes I made when fixing declaration map
  sources ~1.5 years ago in ec0568ba2c8e206372f94164e697b1469bf3f33d
- also to add `cwd` to options

- fix: use `toStrictEqual` everywhere, in order to actually check
  `undefined` properties, as this is necessary for some of the checks
  - I believe the original author may have intended to actually check
    `undefined` given that they wrote it in the test, but maybe did not
    know to use `toStrictEqual` instead of `toEqual`

* refactor(test): use obj spread in get-options-overrides

- instead of re-writing the options multiple times, write up some
  defaults and use object spread
  - and refactor `makeDefaultConfig()` to just use
    `{ ...defaultConfig }` instead to match the rest

- re-write normalizePaths to be a `for ... of` loop instead of using
  `Array.map`
  - simpler / more straightforward than a function with side-effects

- feat: add typings in several places
  - that's why we're using TS and ts-jest right??

* fix(test): update host spec to match latest source

- LanguageServiceHost now requires 3rd argument, cwd, so add that to
  all usage
- add afterDecalarations to transformers

- Jest's test.skip can now use async/await, so do that
  - it was also giving a type error, and this is simpler anyway

- change expected to use `__tests__` directory now

- fix: use `expect.arrayContaining` for `host.getDirectories` test as
  there are more temp directories that get added here, such as
  `build-self` and `coverage`
  - in general, might be less fragile if this used a generated directory
    instead of an actual one
    - but save bigger refactors for later

* refactor(test): use async/await, remove truncate func in host spec

- instead of using Promises with `done()`, use async/await for clearer
  code and less indentation too

- remove the `truncateName` function as it's not needed; `local` will
  result in the same name

- remove commented out test code
  - this seemed to just be there for testing the code, and not
    ready-for-production comments

* refactor: use consts in host spec instead of locals

- basically using pre-defined fixture vars instead of ones defined
  inside the test
  - which is more straightforward, easier to read, and less fragile
  - shorter names too

- also use a __temp dir for auto-generated files instead of creating
  them in the same dir and confusing the editor file tree and potential
  watchers
  - change jest config to make sure only spec files are being watched
  - gitignore __tests__/__temp/ dir in case tests crash etc

* fix(test): update rollupcontext spec to match latest source

- use PluginContext and IContext types instead of `any`
  - we're using TypeScript right??
  - add `debug` level logging in a few places where it was missing

- update stubbedContext to have latest PluginContext properties
  - watcher isn't in there anymore and a few new properties were added
- fix type errors with stubbedContext
  - give it an intersection with IContext for `info` and `debug`
    verbosity levels
  - force the logging funcs to `any` as they don't quite match the
    Rollup types
  - force them to `any` when deleting them as well because they're not
    optional properties

- Note: would be good to not force so much `any` if possible, but this
  may be difficult without more advanced internal Rollup mocks
  - couldn't find any testing packages for this :/

- test: add verbosity expect for debug too
- refactor: context2 -> context
  - there wasn't another one, so just use the same name consistently
    - I'm guessing there was another one at some point in the
      development of this and then it was removed but not renamed

* lint: add __tests__ to lint dirs, fix lint errors

- surprisingly only in jest.config.js?

- really need to update to @typescript-eslint ...

* ci: add unit tests to matrix

- run after all the builds for now
  - it can be done in parallel as a separate job, but then have to
    duplicate the NPM install etc, so may not be optimal that way

- refactor: add test:watch and test:coverage scripts
  - shortcut scripts so don't have to `npm test -- --coverage" etc
  - also remove `--verbose` from `test` as that's not necessary

* test: add unit tests for createFilter

- increases coverage of get-options-overrides significantly
- couldn't figure out `rootDirs` -- either the code or my tests are
  wrong, so just skip that one for now

- refactor: move makeStubbedContext etc into a shared fixtures dir so
  that it can be used for both rollupcontext tests _and_
  createFilter tests
  - in my stylistic opinion, I prefer to put nearly _all_ consts like
    these into fixtures dir
  - configure jest to ignore test helpers in coverage reporting such as
    fixture files

- format: '' -> "", add semicolon in some places
  - I use single quotes and no semicolons, so missed that in a few
    places
    - lint didn't check for that and no prettier auto-format :/

* refactor: use consts, async/await, etc in rollingcache spec

- basically using pre-defined fixture vars instead of ones defined
  inside the test
  - which is more straightforward, easier to read, and less fragile
  - shorter names too
  - left a couple of ones as is where they were only used once very
    quickly -- could make them fixture vars too but 🤷

- use async/await instead of Promises with `done()` etc
- also use more `fs-extra` functions that support Promises instead of
  synchronous `fs` functions (e.g. `existsSync` -> `pathExists`)
  - async should be a small optimization for tests too

- fix: use __temp dir for auto-generated files instead of creating
  them in a fixtures dir and breaking actual fixtures

- format: a few multi-line statements were able to be condensed to a
  single line, so do so
  - esp as multi-line was not helping readability since this is just
    irrelevant test data (may have hampered readability actually)

* docs: add a testing section to CONTRIBUTING.md

- goes over the different ways of running the tests (watch + coverage)
- line about unit and integration tests was moved into this section
  - and altered to reflect the current state of the repo now that a good
    amount of unit tests exist

- also move "Linting and Style" into its own section with a list
- move "fix any failed PR checks" to the top as overall guidance on
  making a PR
  - previously it was in the middle of linting and style, which felt a
    bit disjointed (maybe made sense earlier before builds were in CI?)

- name the last section "Building and Self-Build"; leave content as is
  - well mostly, change the first line as "fastest way to test" is not
    necessarily accurate anymore now that there are actual tests

* fix(test): undo tsTypes -> tsModules changes in source code

- original author, brekk, had made these changes, likely because without
  them, the tests would throw in the source lines where `tsModule` was
  used with things like "Cannot read property 'ModuleKind' of undefined"
  - the actual fix for this is to instead use `setTypescriptModule` from
    tsproxy as this is how it is used in the source
    - it's mainly needed for when an alternate TS is substituted
    - brekk probably didn't know the codebase well enough to know that
    - add `setTypescriptModule` to all specs that need it

- 100% test coverage of tsproxy now too!

- this should hopefully fix the build errors we were getting as well

* test: get host spec customTransformers test working

- it seemed incomplete and that's why it was skipped, no comment there
  stating otherwise, so just modified it a bit to get it to work and
  pass properly

* ci: add Node 14, 16, 18, and macOS, Windows to matrix

- drop Node 10 testing
  - Node 10 went EoL a while ago and was causing the latest version of
    Jest to throw an error
- still test Node 12 since it only went EoL recently, but could drop it
  as well if wanted
  - may want to set `package.json#engines` or update min requirements in
    the README if so, though it likely still works on older Node, we
    just can't easily test it

- add macOS and Windows testing to the matrix since TS and Rollup both
  behave differently on different OSes, in particular with regard to the
  filesystem
  - POSIX paths on Windows, case-insensitivity on macOS

- give the job a name that appears in the PR checks and Actions tab

* refactor: use __temp dir in options-overrides spec

- similar to previous commits, don't use the actual fixtures dir, use
  the `__temp` dir and a subfolder within for this spec file
  specifically so as to not interfere with other tests

* test: 100% coverage for host.ts, refactor host.spec.ts

- test: get the skipped `readFile` test to work
  - `ts.sys.readFile` definitely returns stuff, it's used for snapshots
  - it wasn't working because it was testing the wrong extension,
    `.js` instead of `.ts`
    - I thought this was intentional when I first added consts here, but
      turns out that was actually a mistake by the original author
- refactor: merge the `readFile` tests with the main test suite
  - first I merged them together, but as they were just one-liners, I
    merged them with the first set, since it wasn't particularly
    different from those

- refactor: split up the main test suite into a few commented sections
  - core snapshot functionality, fs functionality, misc
  - a lot less random now
- refactor: use `getDirectories` on the testDir instead of project root
  - much less fragile to use the dir generated here, and no hack-ish
    `arrayContaining()` either
- refactor: one-line the case-insensitive test
  - that simplifies it a lot!
- refactor: use fixed consts for the repetitive default config
  - and use a `testOpts` variable for less fragile testing

- test: add tests for version 2 branches of snapshot funcs
  - these weren't tested before so it had only tested the `|| 0` branch
    of the conditional
  - also actually test `reset` instead of calling it at the beginning
- refactor: no more "dirty checking" of instances' private interfaces
  - we're testing it all through the public interfaces instead!

- test: add a simple test for the new `trace` method

- test: coverage for `after` and `afterDeclarations` transformers
- test: coverage for different `undefined` states of transformers
  - refactor the two test suites as one for `undefined` and one for
    all 3 transformers
  - and put the working one first for naming purposes
  - refactor the `setLanguageService` call as a simpler type coercion
  - remove the transformer interactions in the main test suite

- yea, this is a big commit, but I was refactoring everything anyway and
  this is probably gonna be squashed anyway

* refactor: remove remaining "dirty checking of instance as any"

- no need to check private interfaces in these remaining tests, the
  functionality itself is already tested via the public interface

* fix(test): get tests working on Ubuntu and Windows

- host is only case-sensitive on Linux
  - prev was everything except Windows; so flipped the conditional a bit
- host and TS itself use "/" normalized paths, so use those
  - and add a hacky workaround for a TS bug I managed to find

- formatHost will use OS separators, so no "/"
  - make the test more accurate and less fragile by comparing to
    `process.cwd()` as well -- which should normalize on Windows

* refactor: use consts and shrink check-tsconfig

- think it's a bit easier to read this way, it's only 3 tests after all

* refactor: remove normalizePaths func from get-options-overrides spec

- this isn't necessary and added some complexity (and verbosity)
  - only one dir that needs normalization anymore, and that's just the
    cache dir, so just add it to the const/var fixture instead

- shrink the code a bit as a result too
  - and use a bit different code style to shrink it too

- annnd found a Windows bug in get-options-overrides.ts here too...
  - leave a `// TODO: ` comment here to fix the source as this PR is
    solely focused on tests (i.e. no source changes)

Co-authored-by: Brekk <brekk@brekkbockrath.com>
Co-authored-by: bbockrath <bbockrath@goodgamestudios.com>
2022-05-10 18:04:56 -04:00
Anton Gilgur
e28d2f08b9
docs: split off a CONTRIBUTING.md and improve formatting, grammar, links (#313)
* docs: split off a CONTRIBUTING.md from the README

- condenses the README a bit and uses the standard CONTRIBUTING.md file
  - it's a file I often look for when filing an issue or creating a PR
  - leaves the section still in the README so that users (esp. on NPM)
    will know to go there if they're not aware of that convention

- GitHub also now tells users to read the CONTRIBUTING.md of a repo when
  filing issues or creating PRs, so hopefully this helps point more
  users in the right direction as well

* docs: improve formatting, grammar, and links in CONTRIBUTING.md

- slightly change reference to GH Issue Tracker

- use oxford commas everywhere for clarity
- missing "the" in a few places
- more minor grammatical fixes (missing space, semicolon vs. comma, etc)

- fix: "npm_modules" -> "`node_modules`"
- fix: "npm lint" -> "npm run lint", "npm build" -> "npm run build",
  "npm build-self" -> "npm run build-self"
  - short-hand works in Yarn and for some pre-defined Node scripts, like
    `start` and `test`, but the rest need `run`
- "typescript" -> "TS" (prefer proper "TypeScript" or just "TS")
- use backticks monospace/code formatting where appropriate

- link to GitHub's official docs on forking and making PRs
  - also use the word "standard" instead of "normal" as it's more
    inclusive and reflective that this is a convention/standard
- link to editorconfig site
- link directly to `.editorconfig` with a relative link as well
- reword portion about PR checks as they do run `build` and `build-self`
  nowadays (not sure how old this text is)

- use an ordered list (instead of unordered) for the testing process
  as this is meant to be done in order
2022-05-05 09:25:43 -06:00
Anton Gilgur
895431d3ae
deps: use normalizePath from @rollup/pluginutils (#320)
- this was introduced in v4.1.0 of @rollup/pluginutils:
  https://github.com/rollup/plugins/blob/master/packages/pluginutils/CHANGELOG.md#v410

- this is the same as the code in `normalize.ts` but it uses constants
  from Node and is used by multiple Rollup plugins, so just helps with
  standardization
  - also less code and types to ship in the bundle!

- removed the dist files for `normalize` as well, but didn't do a build
  in this commit as those are usually done in separate commits
2022-05-04 10:17:56 -06:00
Anton Gilgur
462442d6f5
docs: clarify the TS option's defaults (#316)
- "latest 2.x" is no longer accurate and quite outdated (we're on 4.x
  now), so just say it's the peerDep instead
  - @rollup/plugin-typescript calls the default a peerDep too:
    https://github.com/rollup/plugins/tree/master/packages/typescript#typescript

- be more specific that you can pass in a different version or fork of
  TS (like `ttypescript`) through this option
  - follow-up to 8ec49c78f523687deaf6816bc2ea320f16e325c7

- auto-trim some whitespace-only lines
  - my editor does this automatically, and most of the README has
    trimmed whitespace anyway, so this keeps it consistent
2022-05-04 10:16:45 -06:00
Anton Gilgur
971c816bea
docs: update Compatibility section with new names and links (#315)
- `rollup-plugin-` -> `@rollup/plugin-`
  - just less confusion for newer users who may not be aware of the
    previous naming. and up-to-date / current naming anyway

- clarify grammar in `@rollup/plugin-babel` to be a bit more specific
  - remove part about what "it claims", no need for negative tone
- add a link to the Babel plugin's docs for its default extensions
- comment out ellipsis in code samples (closer to valid code)
2022-05-04 10:12:47 -06:00
Anton Gilgur
e5b276b270
deps: remove unneeded @types/colors package (#319)
- it had a deprecation warning on install stating that types were
  built-in now
  - confirmed that my editor picks up the types fine without and that
    builds still work

- auto-alphabetize deps
- update package-lock.json version to match package.json version
  - NPM did both of these automatically when I ran `npm install`
2022-05-04 10:11:03 -06:00
Anton Gilgur
00bf86f156
docs: standardize how issues are referenced (#317)
- fix: missing `#` in `outDir` reference ("83")

- use `org/repo#num` consistently
  - previously was `Microsoft/TypeScript/issues/num` or
    `rollup/issues/num` inconsistently
  - this is how GitHub displays references to other repos in comments as
    well, so consistent with the rest of GH too
  - links haven't changed, just the text of the them

- auto-trim some whitespace-only lines
  - my editor does this automatically, and most of the README has
    trimmed whitespace anyway, so this keeps it consistent
2022-05-04 10:09:38 -06:00
Anton Gilgur
c219228dd6
docs: add link to NPM in monthly downloads badge (#318)
- previously it just linked to the image itself; better to link to the
  source of the stats which is NPM
  - duplicates the other badge's link, but nbd, better than linking to
    an image imo
2022-05-04 10:08:27 -06:00
Anton Gilgur
e4b5880aa6
fix(docs): _.merge doesn't concat arrays (#314)
- it's a deep merge that merges them by index
- the rest of the docs are accurate, just this one mention was incorrect

- eventually should move to shallow merge/replace arrays to better
  reflect how `tsconfig` `extends` works, but just fix the docs for now
2022-05-04 10:07:48 -06:00
ezolenko
4a69b0dbcb - package version 2022-04-21 11:58:44 -06:00
ezolenko
08d2f5bcad - removing semver dependency (refuses to be rolled up for some reason)
- updating dependencies
2022-04-21 11:58:01 -06:00
ezolenko
5a3e58b277 - dependencies 2022-04-21 11:44:23 -06:00
ezolenko
0df5362d39 - updating dependencies 2022-04-21 11:37:40 -06:00
ezolenko
f84afe983b - updating dependencies 2022-04-21 11:30:01 -06:00
Anton Gilgur
bfd27a9180
fix(github): improve formatting of issue template spoilers (#311)
- I originally made the spoilers and while they work (and I would say
  improve readability a good bit), there's also some issues with them
  - I've used them a ton more now so know how to workaround most
    of the issues with them now

- fix: use HTML `code` tag inside of `summary` tag, can't use backticks
  - was mixing MD and HTML before, and this doesn't always work and
    didn't work on GitHub, they just had backticks

- fix: don't duplicate the file name in the heading, just make the
  `summary` have a heading inside it instead
  - use an `h4` same as the `####` that it was before

- feat: add syntax highlighting by adding code blocks for each code
  snippet
  - js for rollup.config.js, json5 for tsconfig (it has comments,
    trailing commas, etc (actually a custom parser, but json5 is close
    enough)), json for package.json, and text for verbose logs
  - also, a lot of people sometimes just paste the code with no code
    block and it formats terribly, so this should help defer that
    (as well as any potential issues that can crop up with unindented
    blocks)
    - the `envinfo` text code block seems to be working well, so
      hopefully this will improve issues too
2022-04-21 11:09:10 -06:00
ezolenko
ff8895103c - prefix on errors #300 2022-03-04 22:37:24 -07:00
Eugene Zolenko
4e9f8fff08
- cleaning up badges 2022-02-01 16:54:38 -07:00
ezolenko
cffc4dae29 - build 0.31.2 2022-02-01 16:50:48 -07:00
Mateusz Burzyński
66449177ee
Add trace method to the LanguageServiceHost to enable usage with traceResolution (#296) 2022-02-01 16:49:04 -07:00
ezolenko
e82277d37d - build with updated dependencies 2021-12-14 12:43:23 -07:00
bluelovers
1008a43abf
chore: should not lock deps version (#293) 2021-12-14 12:40:29 -07:00
ezolenko
21f67e9540 - updating tslib version in dependencies 2021-12-09 10:14:14 -07:00
ezolenko
a9e617a4b0 - package version 2021-11-23 10:23:37 -07:00
ezolenko
b9c2529099 - package version to 31.1 0.31.1 2021-11-23 10:19:10 -07:00
ezolenko
ef4725b5c8 - updating object-hash to 2.2.0 #291 2021-11-23 10:17:44 -07:00
ezolenko
86296a7e7d - package version 2021-11-16 17:49:58 -07:00
ezolenko
c4bfe211eb - removing rollup watch dependency and running npm audit fix 0.31.0 2021-11-16 17:34:59 -07:00
ezolenko
0658aa0ee8 Merge branch 'bluelovers-pr/node-v17-tslib-002' 2021-11-16 17:32:51 -07:00
ezolenko
215173f179 - rebuild 2021-11-16 17:32:28 -07:00
bluelovers
26c927e688 build(dist): build file 2021-11-04 02:29:24 +08:00
bluelovers
34005979e9 fix(tslib): https://github.com/ezolenko/rollup-plugin-typescript2/issues/286 2021-11-04 02:10:43 +08:00
ezolenko
b76ff690be - updating dependencies 2021-05-19 13:28:15 -06:00
dependabot[bot]
37668fec8b
Bump lodash from 4.17.20 to 4.17.21 (#269)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.20 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.20...4.17.21)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-19 13:16:13 -06:00
Eugene Zolenko
d8c4cccb33
Update README.md 2021-02-19 10:14:10 -07:00
ezolenko
8fd8595c0f - self-build to 0.30.0 2021-02-18 09:38:03 -07:00
ezolenko
b6b3738163 - package version 2021-02-18 09:36:03 -07:00
ezolenko
c6f6e52933 - updating dependencies, version to 0.30.0 0.30.0 2021-02-18 09:30:07 -07:00
Eugene Zolenko
8ec49c78f5
Update README.md
#252
2021-01-20 13:31:10 -07:00
ezolenko
eb1dd17bab - allowing ES2020 module type in tsconfig 2020-12-17 16:34:21 -07:00
ezolenko
bd2e04317b - updating dependencies 2020-12-17 16:24:08 -07:00
Brandon Chinn
91846974dc
Add tslib to installation instructions (#253)
* Add tslib to installation instructions for yarn
2020-11-25 12:56:30 -07:00
ezolenko
8d0d49c063 - build 2020-11-20 13:13:57 -07:00
Tony Ross
6fb0e75f53
Fix duplicate output with multiple entry points (#251)
On Windows the normalized paths in resolveId end up in POSIX format.
This cause rollup to treat the returned path as a new piece of content.
This in turn results in duplicate output for references across entry points.

Fixed by normalizing the path to use host OS separators before returning.
2020-11-20 13:11:55 -07:00
ezolenko
5ce7676ad0 - package version 2020-10-30 13:05:08 -06:00
ezolenko
5ab0e788e1 - package version 0.29.0 2020-10-30 13:01:58 -06:00
ezolenko
4cdb7080b8 - build 2020-10-29 09:43:39 -06:00
Nicolas THIERION
e9af09fe0f
fix: use compilerOptions.rootDir to filter files (#249)
When compilerOptions.rootDir is specified, it is used instead of process.cwd() to filter files. 

Possible fix for #237
2020-10-29 09:41:12 -06:00
ezolenko
35b04d73ab - package version 2020-10-16 14:05:05 -06:00