New Netlify-build fails functions-build containing re-export

A project I hadn’t touched for a few months is now failing building functions. The function is an Express API in TypeScript.

I’ve also doublechecked by branching off the passing master, which now fails.

The only difference between the passing and the failing branch are the Netlify build version and the Node version. I don’t think Node is the issue; locally I use Node 18 without problems but that fails on Netlify (while initialising, not while building) due to a different problem (with mongocrypt?).

Excerpt of the old, passing build log:

7:37:41 AM: ❯ Version
7:37:41 AM:   @netlify/build 29.16.3
(...)
7:38:14 AM:   NODE_VERSION: 'v12.18.0',
(...)
7:38:37 AM: Functions bundling                                            
7:38:37 AM: ────────────────────────────────────────────────────────────────
7:38:37 AM: ​
7:38:37 AM: Packaging Functions from netlify/functions directory:
7:38:37 AM:  - express.ts
7:38:37 AM: ​
7:38:38 AM: ​
7:38:38 AM: (Functions bundling completed in 1.1s)

Excerpt of the failing build log:

9:56:08 AM: ❯ Version
9:56:08 AM:   @netlify/build 29.21.1
(...)
9:56:42 AM:   NODE_VERSION: "v12.22.12",
(...)
9:57:05 AM: Functions bundling                                            
9:57:05 AM: ────────────────────────────────────────────────────────────────
9:57:05 AM: ​
9:57:05 AM: Packaging Functions from netlify/functions directory:
9:57:05 AM:  - express.ts
9:57:05 AM: ​
9:57:05 AM: ✘ [ERROR] No matching export in "shared/index.ts" for import "interpolate"
9:57:05 AM:     server/util/email.ts:4:8:
9:57:05 AM:       4 │ import {interpolate, stripMarkdownHTML, stripMarkdownText} from ".....
        ╵         ~~~~~~~~~~~
9:57:05 AM: ✘ [ERROR] No matching export in "shared/index.ts" for import "stripMarkdownHTML"
9:57:05 AM:     server/util/email.ts:4:21:
9:57:05 AM:       4 │ import {interpolate, stripMarkdownHTML, stripMarkdownText} from ".....
        ╵                      ~~~~~~~~~~~~~~~~~
9:57:05 AM: ✘ [ERROR] No matching export in "shared/index.ts" for import "stripMarkdownText"
9:57:05 AM:     server/util/email.ts:4:40:
9:57:05 AM:       4 │ ...erpolate, stripMarkdownHTML, stripMarkdownText} from "../../shared"
9:57:05 AM:         ╵                                 ~~~~~~~~~~~~~~~~~
9:57:05 AM: ✘ [ERROR] No matching export in "shared/index.ts" for import "slugify"
9:57:05 AM:     server/endpoint/class.ts:5:26:
9:57:05 AM:       5 │ import {IMSafeUser, role, slugify, taskType} from "../../shared"
9:57:05 AM:         ╵                           ~~~~~~~
9:57:05 AM: ​
9:57:05 AM: Bundling of function "express" failed                         
9:57:05 AM: ────────────────────────────────────────────────────────────────
9:57:05 AM: ​
9:57:05 AM:   Error message
9:57:05 AM:   Build failed with 4 errors:
9:57:05 AM:   server/endpoint/class.ts:5:26: ERROR: No matching export in "shared/index.ts" for import "slugify"
9:57:05 AM:   server/util/email.ts:4:8: ERROR: No matching export in "shared/index.ts" for import "interpolate"
9:57:05 AM:   server/util/email.ts:4:21: ERROR: No matching export in "shared/index.ts" for import "stripMarkdownHTML"
9:57:05 AM:   server/util/email.ts:4:40: ERROR: No matching export in "shared/index.ts" for import "stripMarkdownText"

The ‘offending’ shared/index.ts:

export * from './role'
export * from './taskType'
export * from './model'
export * from './validation'
export * from './util'

So it looks like the newer Netlify build is unable to handle the re-export (export * from).
Is this something that can be fixed by a specific setting? Or will I be forced to rewrite these exports?

Thanks,

Ron

hi what site on your account is this?

It’s studyblend.

I just tried upgrading TypeScript from 4 to 5, but it didn’t help.

I’ve worked around it for now but it feels flaky.

I had eight of these re-export issues.
Brought down to four by referencing to the actual file the methods are in, instead of the re-exported index.
Then magically ‘fixed’ three more by updating @types/node.
For the last one I simply did a direct import again instead of importing from the re-export.

So the function builds, but I don’t really understand why it failed: there are several other imported re-exports that don’t throw issues.

Hmm, not too sure why this might happen, although we did late last week roll back some changes to which bundler we use for functions that could have affected you.

Could you see if you can get a rebuild now with the codebase that initially caused the problem without your recent changes? If so, I can wrap that up as an escalation for our dev team to look into when they get a chance.

I just reverted one of the fixes I did. It’s a private repo but this is the revert:

- import {IMSafeUser, role, taskType} from '../../shared'
- import {slugify} from '../../shared/util/string'
+ import {IMSafeUser, role, taskType, slugify} from '../../shared'

Netlify throws the same error. It seems to be the same Netlify build though (29.21.1):

9:06:19 AM: Netlify Build                                                 
9:06:19 AM: ────────────────────────────────────────────────────────────────
9:06:19 AM: ​
9:06:19 AM: ❯ Version
9:06:19 AM:   @netlify/build 29.21.1
9:06:19 AM: ​
9:06:19 AM: ❯ Flags
9:06:19 AM:   baseRelDir: true
9:06:19 AM:   buildId: 651d0ead0c6324000854d2a3
9:06:19 AM:   deployId: 651d0ead0c6324000854d2a5
(...)
9:07:13 AM: Functions bundling                                            
9:07:13 AM: ────────────────────────────────────────────────────────────────
9:07:13 AM: ​
9:07:13 AM: Packaging Functions from netlify/functions directory:
9:07:13 AM:  - express.ts
9:07:13 AM: ​
9:07:13 AM: ✘ [ERROR] No matching export in "shared/index.ts" for import "slugify"
9:07:13 AM:     server/endpoint/class.ts:5:36:
9:07:13 AM:       5 │ import {IMSafeUser, role, taskType, slugify} from "../../shared"
9:07:13 AM:         ╵                                     ~~~~~~~
9:07:13 AM: ​
9:07:13 AM: Bundling of function "express" failed                         
9:07:13 AM: ────────────────────────────────────────────────────────────────

The slugify import it fails on is a function definition, the other imports are re-exports as well but they are variable definitions (and an interface).

Mind sharing a reproduction repo we can check and potentially share with the devs?

Sure. It might take a while to isolate and setup since it is a large private repo I cannot share - as is -. I’ll try to set it up this week.

Sure, let us know once you have something, and we can take a look.