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

would you be open to support node[[X].Y] as target to make GitHub Action build artifacts smaller? #1247

Open
iamstarkov opened this issue Jan 27, 2025 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@iamstarkov
Copy link

in the light of 1246 I discovered default target is es2025 and it only es* targets are expected. underlying webpack does support node* as a target, but ncc restricts it. but using es version as a target doesn't make sense for nodejs versions, because es support is fragmented.

I'd like to relax es* only target restriction to include node* as well, to make GitHub Action build artifacts smaller by not transpiling everything to es2015 but rather only to what's missing in node20 for example

@styfle styfle added the help wanted Extra attention is needed label Jan 28, 2025
@styfle
Copy link
Member

styfle commented Jan 28, 2025

The default is actually es2015.

I think adding support for target.startsWith('node') sounds like a good idea.

Its already merging with node14 here:

target: target ? ["node14", target] : "node14",

Feel free to add a PR with a test, thanks!

@iamstarkov
Copy link
Author

I'll give it a go

@iamstarkov
Copy link
Author

I have gyp issues while yarn install and thus I believe can't run tests. Is it something I can easily fix?

yarn install error gyp failed with exit code: 1
~/projects/oss/ncc (fix/1247-node-target) $ yarn install
yarn install v1.22.22
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
warning Workspaces can only be enabled in private projects.
[4/4] 🔨  Building fresh packages...
[-/17] ⠄ waiting...
[-/17] ⠄ waiting...
[8/17] ⠄ canvas
[-/17] ⠄ waiting...
error /Users/vlasta/projects/oss/ncc/node_modules/canvas: Command failed.
Exit code: 1
Command: prebuild-install -r napi || node-gyp rebuild
Arguments: 
Directory: /Users/vlasta/projects/oss/ncc/node_modules/canvas
Output:
prebuild-install warn install No prebuilt binaries found (target=7 runtime=napi arch=arm64 libc= platform=darwin)
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | arm64
gyp info find Python using Python version 3.13.2 found at "/opt/homebrew/opt/[email protected]/bin/python3.13"

gyp http GET https://nodejs.org/download/release/v20.18.3/node-v20.18.3-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v20.18.3/node-v20.18.3-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v20.18.3/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v20.18.3/SHASUMS256.txt
gyp info spawn /opt/homebrew/opt/[email protected]/bin/python3.13
gyp info spawn args [
gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/vlasta/projects/oss/ncc/node_modules/canvas/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/vlasta/Library/Caches/node-gyp/20.18.3/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/vlasta/Library/Caches/node-gyp/20.18.3',
gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/vlasta/Library/Caches/node-gyp/20.18.3/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/vlasta/projects/oss/ncc/node_modules/canvas',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
/bin/sh: pkg-config: command not found
gyp: Call to 'pkg-config pixman-1 --libs' returned exit status 127 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:297:18)
gyp ERR! stack at ChildProcess.emit (node:events:518:28)
gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:293:12)
gyp ERR! System Darwin 24.3.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/vlasta/projects/oss/ncc/node_modules/canvas

@iamstarkov
Copy link
Author

I started in #1248, gotta figure few main quirks and after that will do my best on how to incorporate input/output pairs into ncc's test infra

@iamstarkov
Copy link
Author

iamstarkov commented Feb 16, 2025

I realized this issue is two fold: supporting node as a target and then figure out why Set polyfills are not injected when compiling node22 code to node20. and I decided to address it one by one.

@styfle pls take a look at #1248 when you have time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants