Skip to content
This repository was archived by the owner on May 22, 2024. It is now read-only.

feat!: refactor enums and export types #1392

Merged
merged 1 commit into from
Apr 20, 2023
Merged

feat!: refactor enums and export types #1392

merged 1 commit into from
Apr 20, 2023

Conversation

danez
Copy link
Contributor

@danez danez commented Apr 19, 2023

ZipFunctionOptions, ZipFunctionsOption, Config, and FunctionConfig are now exported because they are needed in build.

Inspired by this Video https://www.youtube.com/watch?v=jjMbPt_H3RQ and by the reported issue in #1382 this is an attempt to fix the issue by removing enums altogether and instead use const objects.

This allows strings to be supplied in the config while also keeping the grouped constants for the different usecases.

BREAKING CHANGE: The exported typescript types for NodeBundlerType, RuntimeType, and
ModuleFormat are not enums anymore but unions of strings. Use the newly exported
NODE_BUNDLER, RUNTIME, and MODULE_FORMAT for constants. Also the types
NodeBundlerType and RuntimeType were renamed to NodeBundlerName and RuntimeName
respectively.

Fixes #1381


For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code 🧑‍💻.
    This ensures we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing
    a typo or something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures your code follows our style guide and
    passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

A picture of a cute animal (not mandatory, but encouraged)

Sorry, something went wrong.

@danez danez self-assigned this Apr 19, 2023
@danez danez requested a review from a team April 19, 2023 14:41
@danez danez changed the title chore: refactor enums and export types feat!: refactor enums and export types Apr 19, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Apr 19, 2023

⏱ Benchmark results

Comparing with 4a8f058

largeDepsEsbuild: 2.1s

⬆️ 2.61% increase vs. 4a8f058

^   2.2s    2.2s                  
│   ┌──┐    ┌──┐            2.1s  
│ ──┼──┼────┼──┼─────2s─────┌──┐──
│   |  |    |  |    ┌──┐    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴──>
    T-3     T-2     T-1      T    
Legend

largeDepsNft: 8.1s

⬆️ 6.32% increase vs. 4a8f058

^   8.7s    8.5s                  
│   ┌──┐    ┌──┐            8.1s  
│ ──┼──┼────┼──┼────7.6s────┌──┐──
│   |  |    |  |    ┌──┐    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴──>
    T-3     T-2     T-1      T    
Legend

largeDepsZisi: 15.5s

⬆️ 0.44% increase vs. 4a8f058

^  16.2s   15.9s                  
│   ┌──┐    ┌──┐   15.5s   15.5s  
│   |  |    |  |    ┌──┐    ┌──┐  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴──>
    T-3     T-2     T-1      T    
Legend

@bijela-gora
Copy link

@danez thanks!

Verified

This commit was signed with the committer’s verified signature.
fanatid Kirill Fomichev
`ZipFunctionOptions`, `ZipFunctionsOption`, `Config`, and `FunctionConfig` are now exported

BREAKING CHANGE: The exported typescript types for `NodeBundlerType`, `RuntimeType`, and
`ModuleFormat` are not enums anymore but unions of strings. Use the newly exported
`NODE_BUNDLER`, `RUNTIME`, and `MODULE_FORMAT` for constants. Also the types
`NodeBundlerType` and `RuntimeType` were renamed to `NodeBundlerName` and `RuntimeName`
respectively.
export { Archiver as ZipArchive } from 'archiver'

// TODO make enum
export type ArchiveFormat = 'none' | 'zip'
export const ARCHIVE_FORMAT = {
Copy link
Contributor

@lukasholzer lukasholzer Apr 20, 2023

Choose a reason for hiding this comment

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

you could use an const enum ARCHIVE_FORMAT as well then the type would be easier to construct ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But then we cannot export the type for external use. const enum does not exist at runtime.

Copy link
Contributor

@lukasholzer lukasholzer left a comment

Choose a reason for hiding this comment

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

LGTM

@danez danez merged commit 71aeff3 into main Apr 20, 2023
@danez danez deleted the enums branch April 20, 2023 13:37
Skn0tt pushed a commit to netlify/build that referenced this pull request May 21, 2024
`ZipFunctionOptions`, `ZipFunctionsOption`, `Config`, and `FunctionConfig` are now exported

BREAKING CHANGE: The exported typescript types for `NodeBundlerType`, `RuntimeType`, and
`ModuleFormat` are not enums anymore but unions of strings. Use the newly exported
`NODE_BUNDLER`, `RUNTIME`, and `MODULE_FORMAT` for constants. Also the types
`NodeBundlerType` and `RuntimeType` were renamed to `NodeBundlerName` and `RuntimeName`
respectively.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NodeBundlerType as enum
3 participants