@@ -159,8 +159,10 @@ _ATTRS = {
159
159
"preserve_symlinks_main" : attr .bool (
160
160
doc = """When True, the --preserve-symlinks-main flag is passed to node.
161
161
162
- This prevents node from following entry script out of runfiles and the sandbox which can happen for some entry
163
- files such as `.mjs` where the fs node patches, which guard the runfiles and sandbox, are not used.
162
+ This prevents node from following an ESM entry script out of runfiles and the sandbox. This can happen for `.mjs`
163
+ ESM entry points where the fs node patches, which guard the runfiles and sandbox, are not applied.
164
+ See https://github.com/aspect-build/rules_js/issues/362 for more information. Once #362 is resolved,
165
+ the default for this attribute can be set to False.
164
166
165
167
This flag was added in Node.js v10.2.0 (released 2018-05-23). If your node toolchain is configured to use a
166
168
Node.js version older than this you'll need to set this attribute to False.
@@ -173,14 +175,16 @@ _ATTRS = {
173
175
doc = """When True, data files and the entry_point file are copied to the Bazel output tree before being passed
174
176
as inputs to runfiles.
175
177
176
- This default to False. It should only be needed if the program manages to skirt the node fs patches and leave
177
- its runfiles and/or sandbox. In that case, setting this to True will prevent the program from following symlinks
178
- into the source tree and it will end up in the output tree instead where node_modules and other inputs the
179
- program may need will be.
178
+ Ideally, the default for this would be False as it is optimal, but there is a yet unresloved issue of ESM imports
179
+ skirting the node fs patches and escaping the sandbox: https://github.com/aspect-build/rules_js/issues/362.
180
+ This is hit in some test popular runners such as mocha, which use native `import()` statements
181
+ (https://github.com/aspect-build/rules_js/pull/353).
180
182
181
- Mocha, for example, has been observed to escape its runfiles & sandbox: https://github.com/aspect-build/rules_js/pull/353.
183
+ A default of True will prevent program such as mocha from following symlinks into the source tree. They will
184
+ escape the sandbox but they will end up in the output tree where node_modules and other inputs required will be
185
+ available. With this in mind, the default will remain true until issue #362 is resolved.
182
186
""" ,
183
- default = False ,
187
+ default = True ,
184
188
),
185
189
"_launcher_template" : attr .label (
186
190
default = Label ("//js/private:js_binary.sh.tpl" ),
0 commit comments