Add support for assets not mentioned in `files` of `package.json`
See original GitHub issueWhile zip-it-and-ship-it right now supports resolving require statements, if I have a path.join(__dirname, 'somefile') statement, it gets ignored by zip-it-and-ship-it, therefore if a package ships some assets, which are not mentioned in files of the package.json, they’re not included by the packing algorithm.
With Photon.js, we’re downloading binary files in the postinstall hook of the package. These files right now are ignored by zip-it-and-ship-it, making Photon.js broken in Netlify functions.
Note: The binaries are not mentioned in the files field of our package.json, as we don’t want to ship the binaries when publishing. Instead, they’re downloaded in the postinstall hook of the @prisma/photon package.
I see a couple of options here:
-
Give package authors an explicit way to add files in addition to
files. This option would, however, require a custom standard, library authors shouldn’t really have to bother about concrete deployment targets like Netlify. -
Just copy over the whole packages, not just what’s mentioned in the
filespart. -
Use smart logic like node-file-trace does (it’s used in Zeit Now). Photon.js is compatible with
node-file-trace, by addingpath.join(path to binary)statements in the code, which are recognized bynode-file-trace.
The first step for this smart logic could basically be, including not only the require statements of a file, but also the path.join / path.resolve statements.
A quick fix could, of course, be having a union of what you have today and the files that node-file-trace suggests.
I know that you’re having a beta implementation, which may have tackled this already, but I don’t have access to the build beta yet. I just filled the beta form, in case that’s needed.
Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)

Top Related StackOverflow Question
Hi @timsuchanek, thanks for reaching out!
For reference purpose, I believe you are speaking about the following
postinstallscript which triggers the following file. Could you please print a tree of files that are typically generated by this Node file?Please note also that the problem you are mentioning are
path.join()is a broader issue: we do not currently support dynamicrequire(), for example when the path is not a string constant (which is your case) or when put inside aifblock. I’ve opened #68 for this specific problem, feel free to provide with some feedback on this.As you correctly pointed out, the beta should include a fix for your particular issue. I am going to make sure you’re included in our beta so you can make sure Photon.js and Netlify Functions work well together 👍
I will bump this issue once you have access 😃
Amazing Tim! Feel free to send us more feedback about the Beta on
netlify/zip-it-and-ship-it(for Netlify Functions) and onnetlify/build(for the rest). 👍