Skip to content

Consolidate checks that test if the current environment is Node #21

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

Closed

Conversation

jakebailey
Copy link
Owner

@jakebailey jakebailey commented Sep 13, 2022

When bundled, it's very likely that the function "require" will actually
exist at runtime, so we can't use this to determine if we are running in
Node. Consolidate that logic and use other things to check instead.

This is still not perfectly accurate, but I don't want to change this
too much, lest someone downstream depend on our inconsistent logic.

There are yet other places this commit does not fix; search for "typeof
process" for more examples.


Please do not comment on this PR. Depending on how this set of PRs evolves, this PR's contents may change entirely based on the order of commits.

This PR is a part of a stack:

  1. Make a few changes to allow all code to be loaded as one project
  2. Explicitly reference ts namespace in tsserverlibrary
  3. Generated module conversion step - unindent
  4. Generated module conversion step - explicitify
  5. Generated module conversion step - stripNamespaces
  6. Generated module conversion step - inlineImports
  7. Generated module conversion step - .git-ignore-blame-revs
  8. Add gitlens settings suggestion
  9. Make processDiagnosticMessages generate a module
  10. Fix up linting, make lint clean
  11. Undo changes needed to load codebase into ts-morph
  12. Add JSDoc eslint rule
  13. Fix all internal JSDoc comments
  14. Convert require calls to imports
  15. Remove typescriptServices, protocol.d.ts, typescript_standalone.d.ts
  16. Get codebase building pre bundling
  17. Add build via esbuild
  18. Add dts bundling
  19. Consolidate checks that test if the current environment is Node (this PR)
  20. Add ts to globalThis in run.js for convenience during debugging
  21. Rename Gulpfile to Herebyfile for improved git diff
  22. Change build system to hereby
  23. Update baselines for corrected line endings in lib files
  24. Use jsonc-parser instead of LKG compiler in build
  25. Modernize localize script, use new XML library
  26. Don't use needsUpdate for quick tasks
  27. Remove mkdirp
  28. Export ts namespace from tsserver for hacky-post patching
  29. Directly import namespaces for improved esbuild output
  30. Ensure ts object passed to plugins contains deprecatedCompat declarations
  31. Move compiler-debug into Debug namespace, which allows the compiler to be tree shaken
  32. Remove Promise redeclaration
  33. Remove globalThisShim and globalThis modification for TypeScriptServicesFactory
  34. Disable slow CodeQL queries
  35. Remove outFiles from launch.json
  36. Remove dynamicImport and setDynamicImport

@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch from 9702a2e to 63ac570 Compare September 13, 2022 20:28
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from 1927056 to 275c748 Compare September 13, 2022 20:28
@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch 7 times, most recently from 142f87b to 6382230 Compare September 16, 2022 05:43
@jakebailey jakebailey changed the title Work around api-extractor import bug Eliminate exportAsModule.ts Sep 16, 2022
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from 275c748 to b2807ab Compare September 16, 2022 05:43
@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch 2 times, most recently from effc622 to 99a9841 Compare September 19, 2022 20:38
@jakebailey jakebailey changed the title Eliminate exportAsModule.ts Fully remove dynamicImportCompat Sep 19, 2022
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from b2807ab to 1a97904 Compare September 19, 2022 20:38
@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch from 99a9841 to da5cddf Compare September 20, 2022 05:06
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from 1a97904 to c388116 Compare September 20, 2022 05:06
@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch from da5cddf to 77c9a92 Compare September 20, 2022 05:11
@jakebailey jakebailey changed the title Fully remove dynamicImportCompat Add babel for let/const lowering Sep 20, 2022
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from c388116 to 2a701a0 Compare September 20, 2022 05:11
@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch from 77c9a92 to 96794e4 Compare September 20, 2022 17:00
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from 2a701a0 to c292ea6 Compare September 20, 2022 17:00
@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch from 96794e4 to fe854f0 Compare September 24, 2022 16:51
@jakebailey jakebailey changed the title Add babel for let/const lowering Add build via esbuild Sep 24, 2022
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from c292ea6 to bb4001f Compare September 24, 2022 16:51
@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch from fe854f0 to 864d946 Compare September 26, 2022 23:09
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from bb4001f to 5813ec9 Compare September 26, 2022 23:10
@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch from 864d946 to 5d1269d Compare September 27, 2022 21:59
@jakebailey jakebailey changed the title Add build via esbuild Try and fix up LKG Sep 27, 2022
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from 5813ec9 to 58f41e1 Compare September 27, 2022 21:59
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from 8642f50 to 084b7ea Compare October 24, 2022 23:15
@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch from f84fe87 to a0d1831 Compare October 25, 2022 02:24
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from 084b7ea to aab52d6 Compare October 25, 2022 02:24
@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch from a0d1831 to b7bb4b4 Compare October 27, 2022 04:23
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from aab52d6 to de670ad Compare October 27, 2022 04:24
@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch from b7bb4b4 to b98da1f Compare October 27, 2022 17:42
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from de670ad to 384fe8d Compare October 27, 2022 17:42
@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch from b98da1f to 510bf54 Compare October 28, 2022 02:24
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from 384fe8d to 026e6e9 Compare October 28, 2022 02:24
@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch from 510bf54 to 93f297c Compare October 31, 2022 21:35
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from 026e6e9 to af1a0d3 Compare October 31, 2022 21:35
@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch from 93f297c to 1b88373 Compare November 2, 2022 00:45
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from af1a0d3 to d93aadf Compare November 2, 2022 00:45
@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch from 1b88373 to fc68862 Compare November 2, 2022 16:57
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from d93aadf to 2601d2b Compare November 2, 2022 16:57
@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch from fc68862 to e0ee7b5 Compare November 2, 2022 19:47
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from 2601d2b to fd98dd3 Compare November 2, 2022 19:47
@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch from e0ee7b5 to 3a27a32 Compare November 6, 2022 21:52
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from fd98dd3 to 231f965 Compare November 6, 2022 21:52
@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch from 3a27a32 to f4e3ead Compare November 6, 2022 21:58
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from 231f965 to 8e7607f Compare November 6, 2022 21:58
@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch from f4e3ead to 704bc03 Compare November 7, 2022 03:53
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from 8e7607f to ba01ac8 Compare November 7, 2022 03:53
@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch from 704bc03 to 438d60c Compare November 7, 2022 19:28
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from ba01ac8 to cd0bfbc Compare November 7, 2022 19:28
@jakebailey jakebailey force-pushed the transform-stack-commit-18 branch from 438d60c to 0a33553 Compare November 7, 2022 21:38
When bundled, it's very likely that the function "require" will actually
exist at runtime, so we can't use this to determine if we are running in
Node. Consolidate that logic and use other things to check instead.

This is still not perfectly accurate, but I don't want to change this
_too_ much, lest someone downstream depend on our inconsistent logic.

There are yet other places this commit does not fix; search for "typeof
process" for more examples.
@jakebailey jakebailey force-pushed the transform-stack-commit-19 branch from cd0bfbc to 423ad68 Compare November 7, 2022 21:38
@jakebailey jakebailey closed this Nov 7, 2022
@jakebailey jakebailey deleted the transform-stack-commit-19 branch November 7, 2022 23:55
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.

1 participant