Skip to content
Browse files

tools: allow single JS file for --link-module

The description for the --link-module configuration option is as
$ ./configure --help | grep -A 5 'link-module'
                      Path to a JS file to be bundled in the binary as a
                      builtin. This module will be referenced by path
                      without extension; e.g. /root/x/y.js will be
                      referenced via require('root/x/y'). Can be used
                      multiple times

This lead me to think that it was possible to specify a file like this:
$ ./configure --link-module=something.js
$ NODE_DEBUG=mkcodecache make -j8

This will lead to a compilation error as an entry in the source_ map in will end up having an empty string as its key:
source_.emplace("", UnionBytes{_raw, 105});

This will then be used by CodeCacheBuilder when it iterates over the
module ids, which will lead to the following compilation errors:

/node/out/Release/obj/gen/ warning:
ISO C++17 does not allow a decomposition group to be
empty [-Wempty-decomposition]
static const uint8_t [] = {
/node/out/Release/obj/gen/ warning:
decomposition declarations are a C++17 extension [-Wc++17-extensions]
static const uint8_t [] = {
/node/out/Release/obj/gen/ error:
decomposition declaration cannot be declared 'static'
static const uint8_t [] = {
/node/out/Release/obj/gen/ error:
decomposition declaration cannot be declared with type 'const uint8_t'
(aka 'const unsigned char'); declared type must be 'auto' or
reference to 'auto'
static const uint8_t [] = {
/node/out/Release/obj/gen/ error:
excess elements in scalar initializer
static const uint8_t [] = {
/node/out/Release/obj/gen/ error:
expected expression
/node/out/Release/obj/gen/ error:
no matching function for call to 'arraysize'
      static_cast<int>(arraysize()), policy
../src/util.h:667:18: note: candidate function template not viable:
requires 1 argument, but 0 were provided
constexpr size_t arraysize(const T (&)[N]) {
2 warnings and 5 errors generated.

This commit suggests that passing a single file be allowed by modifying

PR-URL: #28443
Reviewed-By: Luigi Pinca <>
Reviewed-By: Rich Trott <>
  • Loading branch information...
danbev authored and targos committed Jun 27, 2019
1 parent cb16229 commit 1011a1792c9e8e86152a172c80d729045e8f80c3
Showing with 22 additions and 1 deletion.
  1. +6 −0 Makefile
  2. +14 −0 test/tools/
  3. +2 −1 tools/
@@ -294,6 +294,10 @@ jstest: build-addons build-js-native-api-tests build-node-api-tests ## Runs addo

.PHONY: tooltest
@$(PYTHON) test/tools/

.PHONY: coverage-run-js
$(RM) -r out/$(BUILDTYPE)/.coverage
@@ -311,6 +315,7 @@ test: all ## Runs default tests, linters, and builds docs.
$(MAKE) -s build-node-api-tests
$(MAKE) -s cctest
$(MAKE) -s jstest
$(MAKE) -s tooltest

.PHONY: test-only
test-only: all ## For a quick test, does not run linter or build docs.
@@ -319,6 +324,7 @@ test-only: all ## For a quick test, does not run linter or build docs.
$(MAKE) build-node-api-tests
$(MAKE) cctest
$(MAKE) jstest
$(MAKE) tooltest

# Used by `make coverage-test`
test-cov: all
@@ -0,0 +1,14 @@
import unittest
import sys, os
'..', '..', 'tools')))
from js2c import NormalizeFileName

class Js2ctest(unittest.TestCase):
def testNormalizeFileName(self):
self.assertEqual(NormalizeFileName('dir/mod.js'), 'mod')
self.assertEqual(NormalizeFileName('deps/mod.js'), 'internal/deps/mod')
self.assertEqual(NormalizeFileName('mod.js'), 'mod')

if __name__ == '__main__':
@@ -261,7 +261,8 @@ def NormalizeFileName(filename):
split = ['internal'] + split
else: # `lib/**/*.js` so drop the 'lib' part
split = split[1:]
filename = '/'.join(split)
if len(split):
filename = '/'.join(split)
return os.path.splitext(filename)[0]

0 comments on commit 1011a17

Please sign in to comment.
You can’t perform that action at this time.