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

feat: always transform V2 functions #1597

Merged
merged 5 commits into from
Oct 10, 2023
Merged

Conversation

eduardoboucas
Copy link
Member

Summary

I realised that we were only transforming V2 functions (i.e. running them through esbuild) when the extension was a TypeScript extension. But we should also do it for JavaScript functions, since bundling local imports is essential to ensure imports between ESM and CJS work as expected.

I ended up renaming the "TS transformer" to a generic transformer, and I moved it into its own file.

@eduardoboucas eduardoboucas requested a review from a team as a code owner October 9, 2023 22:43
* Returns the module format that should be used when transpiling a TypeScript
* file.
*/
const getTSModuleFormat = async (
Copy link
Member Author

Choose a reason for hiding this comment

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

This is now called getModuleFormat in transformer.ts.

rewrites: Map<string, string>
}

const getTypeScriptTransformer = async (
Copy link
Member Author

Choose a reason for hiding this comment

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

This is now called getTransformer in transformer.ts.

path: string
}

export const transpileTS = async ({ bundle = false, config, format, name, path }: TranspileTSOptions) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is now called transform in transformer.ts.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2023

⏱ Benchmark results

Comparing with 1eccedc

largeDepsEsbuild: 2.6s

⬇️ 9.45% decrease vs. 1eccedc

^                           3.7s                                                                          
│                           ┌──┐                                                                          
│                           |  |                                                                          
│                   3.1s    |  |                                                                          
│                   ┌──┐    |  |                                     3s                                   
│   2.8s            |  |    |  |    2.7s            2.7s            ┌──┐            2.7s    2.8s          
│ ──┌──┐────2.6s────┼──┼────┼──┼────┌──┐────────────┌──┐────2.6s────┼──┼────2.6s────┌──┐────┌──┐────2.6s──
│   |  |    ┌──┐    |  |    |  |    |  |    2.4s    |  |    ┌──┐    |  |    ┌──┐    |  |    |  |    ┌──┐  
│   |  |    |  |    |  |    |  |    |  |    ┌──┐    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-12    T-11    T-10    T-9     T-8     T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend

largeDepsNft: 8.1s

⬇️ 4.42% decrease vs. 1eccedc

^                          12.1s                                                                          
│                           ┌──┐                                                                          
│                           |  |                                                                          
│                  10.1s    |  |                                                                          
│                   ┌──┐    |  |                                                                          
│                   |  |    |  |                                    9.3s                                  
│   8.3s            |  |    |  |    8.3s                            ┌──┐            8.4s    8.4s          
│ ──┌──┐────8.1s────┼──┼────┼──┼────┌──┐─────────────8s─────7.7s────┼──┼────7.9s────┌──┐────┌──┐────8.1s──
│   |  |    ┌──┐    |  |    |  |    |  |    7.5s    ┌──┐    ┌──┐    |  |    ┌──┐    |  |    |  |    ┌──┐  
│   |  |    |  |    |  |    |  |    |  |    ┌──┐    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-12    T-11    T-10    T-9     T-8     T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend

largeDepsZisi: 15.9s

⬆️ 0.06% increase vs. 1eccedc

^                          22.4s                                                                          
│                           ┌──┐                                                                          
│                           |  |                                                                          
│                  19.3s    |  |                                                                          
│                   ┌──┐    |  |                                   17.9s                                  
│                   |  |    |  |                                    ┌──┐           16.3s                  
│ ─15.9s───15.5s────┼──┼────┼──┼───15.7s───────────15.7s───15.1s────┼──┼───15.4s────┌──┐───15.9s───15.9s──
│   ┌──┐    ┌──┐    |  |    |  |    ┌──┐   14.4s    ┌──┐    ┌──┐    |  |    ┌──┐    |  |    ┌──┐    ┌──┐  
│   |  |    |  |    |  |    |  |    |  |    ┌──┐    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-12    T-11    T-10    T-9     T-8     T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend

@eduardoboucas eduardoboucas marked this pull request as draft October 9, 2023 23:19
@eduardoboucas eduardoboucas marked this pull request as ready for review October 10, 2023 08:33
Copy link
Contributor

@Skn0tt Skn0tt left a comment

Choose a reason for hiding this comment

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

I found the diff hard to review - but I think it looks good. And since you didn't touch a lot of tests, i'm trusting this to be fine.

@eduardoboucas eduardoboucas merged commit c9e5384 into main Oct 10, 2023
10 checks passed
@eduardoboucas eduardoboucas deleted the feat/v2-always-bundle branch October 10, 2023 08:47
Skn0tt pushed a commit to netlify/build that referenced this pull request May 21, 2024
* feat: always bundle V2 functions

* refactor: rename to `transformer`

* refactor: always bundle

* refactor: update conditions

* chore: update tests
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.

2 participants