Skip to content
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

feat!: convert to ESM and vitest #1230

Merged
merged 7 commits into from Oct 28, 2022
Merged

feat!: convert to ESM and vitest #1230

merged 7 commits into from Oct 28, 2022

Conversation

danez
Copy link
Contributor

@danez danez commented Oct 27, 2022

πŸŽ‰ Thanks for submitting a pull request! πŸŽ‰

Summary

Fixes #749

This converts zisi to pure ESM. It also migrates from ava to vitest.


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)

@danez danez requested review from lukasholzer and a team October 27, 2022 08:48
@danez danez self-assigned this Oct 27, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Oct 27, 2022

⏱ Benchmark results

Comparing with dec4d3f

largeDepsEsbuild: 5.5s

⬇️ 35.31% decrease vs. dec4d3f

^                                   7.5s          
β”‚                           7.2s    β”Œβ”€β”€β”          
β”‚           6.7s            β”Œβ”€β”€β”    |  |          
β”‚           β”Œβ”€β”€β”    6.5s    |  |    |  |          
β”‚ β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”Όβ”€β”€β”€β”€β”Œβ”€β”€β”β”€β”€β”€β”€β”Όβ”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚   5.7s    |  |    |  |    |  |    |  |    5.5s  
β”‚   β”Œβ”€β”€β”    |  |    |  |    |  |    |  |    β”Œβ”€β”€β”  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-5     T-4     T-3     T-2     T-1      T    
Legend

largeDepsNft: 29.3s

⬇️ 24.58% decrease vs. dec4d3f

^                          36.6s   36.6s          
β”‚                   34s     β”Œβ”€β”€β”    β”Œβ”€β”€β”          
β”‚                   β”Œβ”€β”€β”    |  |    |  |          
β”‚ ─────────31.2s────┼──┼────┼──┼────┼──┼──────────
β”‚           β”Œβ”€β”€β”    |  |    |  |    |  |   29.3s  
β”‚   28s     |  |    |  |    |  |    |  |    β”Œβ”€β”€β”  
β”‚   β”Œβ”€β”€β”    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-5     T-4     T-3     T-2     T-1      T    
Legend

largeDepsZisi: 41.2s

⬇️ 35.26% decrease vs. dec4d3f

^                                  55.7s          
β”‚                          53.5s    β”Œβ”€β”€β”          
β”‚                           β”Œβ”€β”€β”    |  |          
β”‚           47s    48.5s    |  |    |  |          
β”‚ β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Œβ”€β”€β”β”€β”€β”€β”€β”Œβ”€β”€β”β”€β”€β”€β”€β”Όβ”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  42.9s    |  |    |  |    |  |    |  |   41.2s  
β”‚   β”Œβ”€β”€β”    |  |    |  |    |  |    |  |    β”Œβ”€β”€β”  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
β”‚   |  |    |  |    |  |    |  |    |  |    |β–’β–’|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-5     T-4     T-3     T-2     T-1      T    
Legend

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.

❀️ vitest πŸ’―

@@ -17,7 +17,7 @@ jobs:
with:
token: ${{ steps.get-token.outputs.token }}
release-type: node
package-name: '@netlify/@netlify/zip-it-and-ship-it'
package-name: '@netlify/zip-it-and-ship-it'
Copy link
Contributor

Choose a reason for hiding this comment

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

how did this worked πŸ˜‚

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No Idea

@@ -19,4 +20,9 @@ const runBenchmarks = async function () {
console.log(`${largeDepsEsbuild}ms`)
}

runBenchmarks()
try {
await runBenchmarks()
Copy link
Contributor

Choose a reason for hiding this comment

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

Just as information you could now use the vitest bench benchmarking functionality. Nothing to change here but just as a FYI

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I was wondering, but didn't want to add even more changes.
Not super happy with vitest yet, had to do some workarounds, so do not want to buy in yet fully :)

@@ -8,6 +8,7 @@ import endOfStream from 'end-of-stream'

export { Archiver as ZipArchive } from 'archiver'

// TODO make enum
Copy link
Contributor

Choose a reason for hiding this comment

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

Still todo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, afterwards.

// @ts-expect-error vitest with esbuild already resolves the default export, whereas Node.js does not
const resolveDependency: typeof nftResolveDependency.default = nftResolveDependency.default
? nftResolveDependency.default
: nftResolveDependency
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reported here: vitest-dev/vitest#2219

export const importFunctionFile = async function <T = any>(functionPath: string): Promise<T> {
// We use relative paths here, because vitest cannot handle absolute paths or urls :(
// eslint-disable-next-line import/no-dynamic-require
const result = await import(`/@fs/${functionPath}`)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reported here vitest-dev/vitest#2218

@danez danez merged commit c8e1d4d into main Oct 28, 2022
@danez danez deleted the esm branch October 28, 2022 08:13
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.

Use pure ES modules
2 participants