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

Build Issue in Version 1.9.0 #351

Open
omochi opened this issue Oct 25, 2024 · 0 comments
Open

Build Issue in Version 1.9.0 #351

omochi opened this issue Oct 25, 2024 · 0 comments

Comments

@omochi
Copy link

omochi commented Oct 25, 2024

In my environment, when I check out version 1.9.0 and run npm install, I encounter the following error.

npm error code 1
npm error path /Users/omochi/temp/fontkit/node_modules/lmdb
npm error command failed
npm error command sh -c node-gyp-build
npm error CXX(target) Release/obj.target/lmdb/src/lmdb-js.o
npm error gyp info it worked if it ends with ok
npm error gyp info using [email protected]
npm error gyp info using [email protected] | darwin | arm64
npm error gyp info find Python using Python version 3.9.6 found at "/Applications/Xcode16.2-beta.app/Contents/Developer/usr/bin/python3"
npm error gyp info spawn /Applications/Xcode16.2-beta.app/Contents/Developer/usr/bin/python3
npm error gyp info spawn args [
npm error gyp info spawn args '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm error gyp info spawn args 'binding.gyp',
npm error gyp info spawn args '-f',
npm error gyp info spawn args 'make',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/Users/omochi/temp/fontkit/node_modules/lmdb/build/config.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/Users/omochi/Library/Caches/node-gyp/22.5.1/include/node/common.gypi',
npm error gyp info spawn args '-Dlibrary=shared_library',
npm error gyp info spawn args '-Dvisibility=default',
npm error gyp info spawn args '-Dnode_root_dir=/Users/omochi/Library/Caches/node-gyp/22.5.1',
npm error gyp info spawn args '-Dnode_gyp_dir=/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp',
npm error gyp info spawn args '-Dnode_lib_file=/Users/omochi/Library/Caches/node-gyp/22.5.1/<(target_arch)/node.lib',
npm error gyp info spawn args '-Dmodule_root_dir=/Users/omochi/temp/fontkit/node_modules/lmdb',
npm error gyp info spawn args '-Dnode_engine=v8',
npm error gyp info spawn args '--depth=.',
npm error gyp info spawn args '--no-parallel',
npm error gyp info spawn args '--generator-output',
npm error gyp info spawn args 'build',
npm error gyp info spawn args '-Goutput_dir=.'
npm error gyp info spawn args ]
npm error gyp info spawn make
npm error gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm error In file included from ../src/lmdb-js.cpp:1:
npm error In file included from ../src/lmdb-js.h:32:
npm error In file included from ../../nan/nan.h:178:
npm error ../../nan/nan_callbacks.h:55:23: error: no member named 'AccessorSignature' in namespace 'v8'
npm error    55 | typedef v8::Local<v8::AccessorSignature> Sig;
npm error       |                   ~~~~^
npm error In file included from ../src/lmdb-js.cpp:1:
npm error In file included from ../src/lmdb-js.h:32:
npm error ../../nan/nan.h:2544:8: error: no matching member function for call to 'SetAccessor'
npm error  2544 |   tpl->SetAccessor(
npm error       |   ~~~~~^~~~~~~~~~~
npm error /Users/omochi/Library/Caches/node-gyp/22.5.1/include/node/v8-template.h:1055:8: note: candidate function not viable: no known conversion from 'v8::AccessControl' to 'PropertyAttribute' for 5th argument
npm error  1055 |   void SetAccessor(
npm error       |        ^
npm error  1056 |       Local<Name> name, AccessorNameGetterCallback getter,
npm error  1057 |       AccessorNameSetterCallback setter = nullptr,
npm error  1058 |       Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
npm error       |                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm error /Users/omochi/Library/Caches/node-gyp/22.5.1/include/node/v8-template.h:1049:8: note: candidate function not viable: no known conversion from 'imp::NativeGetter' (aka 'void (*)(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value> &)') to 'AccessorGetterCallback' (aka 'void (*)(Local<String>, const PropertyCallbackInfo<Value> &)') for 2nd argument
npm error  1049 |   void SetAccessor(
npm error       |        ^
npm error  1050 |       Local<String> name, AccessorGetterCallback getter,
npm error       |                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm error In file included from ../src/lmdb-js.cpp:1:
npm error In file included from ../src/lmdb-js.h:29:
npm error In file included from /Users/omochi/Library/Caches/node-gyp/22.5.1/include/node/v8.h:24:
npm error In file included from /Users/omochi/Library/Caches/node-gyp/22.5.1/include/node/v8-array-buffer.h:12:
npm error /Users/omochi/Library/Caches/node-gyp/22.5.1/include/node/v8-local-handle.h:269:19: error: static assertion failed due to requirement 'std::is_base_of<v8::Value, v8::Data>::value': type check
npm error   269 |     static_assert(std::is_base_of<T, S>::value, "type check");
npm error       |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm error ../../nan/nan_callbacks_12_inl.h:175:20: note: in instantiation of function template specialization 'v8::Local<v8::Value>::Local<v8::Data>' requested here
npm error   175 |       cbinfo(info, obj->GetInternalField(kDataIndex));
npm error       |                    ^
npm error 3 errors generated.
npm error make: *** [Release/obj.target/lmdb/src/lmdb-js.o] Error 1
npm error gyp ERR! build error 
npm error gyp ERR! stack Error: `make` failed with exit code: 2
npm error gyp ERR! stack at ChildProcess.<anonymous> (/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
npm error gyp ERR! System Darwin 24.1.0
npm error gyp ERR! command "/opt/homebrew/Cellar/node/22.5.1/bin/node" "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm error gyp ERR! cwd /Users/omochi/temp/fontkit/node_modules/lmdb
npm error gyp ERR! node -v v22.5.1
npm error gyp ERR! node-gyp -v v10.1.0
npm error gyp ERR! not ok
npm error A complete log of this run can be found in: /Users/omochi/.npm/_logs/2024-10-25T00_59_09_454Z-debug-0.log

This issue can be resolved simply by running npm update. However, a new error appears afterward.

> parcel build

(node:7396) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
🚨 Build failed.

@parcel/core: Failed to resolve '@swc/helpers/cjs/_define_property.cjs' from './node_modules/@parcel/transformer-js/lib/JSTransformer.js'

  /Users/omochi/temp/fontkit/src/WOFFFont.js:1:1
  > 1 | import TTFFont from './TTFFont';
  >   | ^
    2 | import WOFFDirectory from './tables/WOFFDirectory';
    3 | import tables from './tables';

@parcel/resolver-default: External dependency "@swc/helpers" does not satisfy required semver range "^0.5.0".

  /Users/omochi/temp/fontkit/package.json:52:21
    51 |   "dependencies": {
  > 52 |     "@swc/helpers": "^0.3.13",
  >    |                     ^^^^^^^^^ Found this conflicting requirement.
    53 |     "brotli": "^1.3.2",
    54 |     "clone": "^2.1.2",

  💡 Update the dependency on "@swc/helpers" to satisfy "^0.5.0".

ERROR: "build" exited with 1.
npm error code 1
npm error path /Users/omochi/temp/fontkit
npm error command failed
npm error command sh -c run-s clean trie:** build
npm error A complete log of this run can be found in: /Users/omochi/.npm/_logs/2024-10-25T01_05_26_588Z-debug-0.log

This issue can be resolved by updating @swc/helpers from ^0.3.13 to ^0.5.13. However, a new error appears afterward.

> parcel build

(node:9777) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
🚨 Build failed.

@parcel/core: Failed to resolve '../iconv-lite.cjs' from './src/CmapProcessor.js'

  /Users/omochi/temp/fontkit/src/CmapProcessor.js:5:19
    4 | import { range } from './utils';
  > 5 | import iconv from '../iconv-lite.cjs';
  >   |                   ^^^^^^^^^^^^^^^^^^^
    6 | 
    7 | export default class CmapProcessor {

@parcel/resolver-default: External dependency ".." is not declared in package.json.

  /Users/omochi/temp/fontkit/package.json:51:3
    50 |   },
  > 51 |   "dependencies": {
  >    |   ^^^^^^^^^^^^^^
    52 |     "@swc/helpers": "^0.5.13",
    53 |     "brotli": "^1.3.2",

  💡 Add ".." as a dependency.

ERROR: "build" exited with 1.

This issue can be resolved by removing the following alias setting in package.json:

  "alias": {
    "./iconv-lite.cjs": "clone"
  }

What is the intent behind aliasing ./iconv-lite.cjs to clone in this setting?
The clone module clearly cannot be a substitute for iconv-lite.

With the above changes, both npm install and npm update succeed.

However, npm test fails with the following error.

  540 passing (447ms)
  7 pending
  1 failing

  1) character to glyph mapping
       basic cmap handling
         should support legacy encodings when no unicode cmap is found:
     TypeError: (0 , $parcel$interopDefault(...)).encodingExists is not a function
      at new $5d24cfe1a4cd83bb$export$2e2bcd8739ae039 (file:///Users/omochi/temp/fontkit/dist/module.mjs:5421:87)
      at get _cmapProcessor (file:///Users/omochi/temp/fontkit/dist/module.mjs:12527:16)
      at descriptor.get (file:///Users/omochi/temp/fontkit/dist/module.mjs:85:29)
      at $7de97f725b51e05a$export$2e2bcd8739ae039.glyphForCodePoint (file:///Users/omochi/temp/fontkit/dist/module.mjs:12550:35)
      at $7de97f725b51e05a$export$2e2bcd8739ae039.glyphsForString (file:///Users/omochi/temp/fontkit/dist/module.mjs:12590:30)
      at Context.<anonymous> (file:///Users/omochi/temp/fontkit/test/glyph_mapping.js:40:25)
      at process.processImmediate (node:internal/timers:483:21)

Upon investigating the error, it seems that an exception occurs in iconv-lite.cjs when calling require('iconv-lite'), resulting in an empty object being exported.
In CmapProcessor.js, the code checks whether iconv is truthy, but since the empty object returned upon failure is truthy, the check fails.
While this logic should also be fixed, the test case states should support legacy encodings when no unicode cmap is found, so the inability to load iconv-lite is a more significant issue.
I believe this is caused by the configuration when bundling with Parcel, but since I am not familiar with it, I couldn’t determine the solution.

As mentioned in #350, I am using fontkit as a dependency in pdfkit, so I would like to stabilize and maintain the build and tests for the 1.9.x series. Could you advise me on how to resolve this issue?

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

No branches or pull requests

1 participant