Commit ececd22
src: implement IsInsideNodeModules() in C++
This previously compiles a script and run it in a new context
to avoid global pollution, which is more complex than necessary
and can be too slow for it to be reused in other cases. The
new implementation just checks the frames in C++ which is safe
from global pollution, faster and simpler.
The previous implementation also had a bug when the call site
is in a ESM, because ESM have URLs as their script names,
which don't start with '/' or '\' and will be skipped. The new
implementation removes the skipping to fix it for ESM.
PR-URL: #55286
Backport-PR-URL: #56927
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Refs: #526971 parent 4fba019 commit ececd22Copy full SHA for ececd22
File tree
Expand file treeCollapse file tree
10 files changed
+114
-31
lines changedOpen diff view settings
Filter options
- lib
- internal
- src
- test
- fixtures/warning_node_modules
- node_modules
- new-buffer-cjs
- new-buffer-esm
- parallel
Expand file treeCollapse file tree
10 files changed
+114
-31
lines changedOpen diff view settings
Collapse file
+4-2Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
77 | 77 | |
78 | 78 | |
79 | 79 | |
| 80 | + |
80 | 81 | |
81 | 82 | |
82 | 83 | |
83 | | - |
84 | 84 | |
85 | 85 | |
86 | 86 | |
| ||
176 | 176 | |
177 | 177 | |
178 | 178 | |
179 | | - |
| 179 | + |
180 | 180 | |
181 | 181 | |
182 | 182 | |
183 | 183 | |
184 | 184 | |
185 | 185 | |
| 186 | + |
| 187 | + |
186 | 188 | |
187 | 189 | |
188 | 190 | |
|
Collapse file
-29Lines changed: 0 additions & 29 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
3 | 3 | |
4 | 4 | |
5 | 5 | |
6 | | - |
7 | 6 | |
8 | 7 | |
9 | 8 | |
| ||
35 | 34 | |
36 | 35 | |
37 | 36 | |
38 | | - |
39 | 37 | |
40 | | - |
41 | 38 | |
42 | 39 | |
43 | 40 | |
| ||
509 | 506 | |
510 | 507 | |
511 | 508 | |
512 | | - |
513 | | - |
514 | | - |
515 | | - |
516 | | - |
517 | | - |
518 | | - |
519 | | - |
520 | | - |
521 | | - |
522 | | - |
523 | | - |
524 | | - |
525 | | - |
526 | | - |
527 | | - |
528 | | - |
529 | | - |
530 | | - |
531 | | - |
532 | | - |
533 | | - |
534 | | - |
535 | | - |
536 | | - |
537 | 509 | |
538 | 510 | |
539 | 511 | |
| ||
916 | 888 | |
917 | 889 | |
918 | 890 | |
919 | | - |
920 | 891 | |
921 | 892 | |
922 | 893 | |
|
Collapse file
+50Lines changed: 50 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
254 | 254 | |
255 | 255 | |
256 | 256 | |
| 257 | + |
| 258 | + |
| 259 | + |
| 260 | + |
| 261 | + |
| 262 | + |
| 263 | + |
| 264 | + |
| 265 | + |
| 266 | + |
| 267 | + |
| 268 | + |
| 269 | + |
| 270 | + |
| 271 | + |
| 272 | + |
| 273 | + |
| 274 | + |
| 275 | + |
| 276 | + |
| 277 | + |
| 278 | + |
| 279 | + |
| 280 | + |
| 281 | + |
| 282 | + |
| 283 | + |
| 284 | + |
| 285 | + |
| 286 | + |
| 287 | + |
| 288 | + |
| 289 | + |
| 290 | + |
| 291 | + |
| 292 | + |
| 293 | + |
| 294 | + |
| 295 | + |
| 296 | + |
| 297 | + |
| 298 | + |
| 299 | + |
| 300 | + |
| 301 | + |
| 302 | + |
| 303 | + |
| 304 | + |
257 | 305 | |
258 | 306 | |
259 | 307 | |
| ||
269 | 317 | |
270 | 318 | |
271 | 319 | |
| 320 | + |
272 | 321 | |
273 | 322 | |
274 | 323 | |
| ||
338 | 387 | |
339 | 388 | |
340 | 389 | |
| 390 | + |
341 | 391 | |
342 | 392 | |
343 | 393 | |
|
Collapse file
test/fixtures/warning_node_modules/new-buffer-cjs.js
Copy file name to clipboardExpand all lines: test/fixtures/warning_node_modules/new-buffer-cjs.js+1Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file
test/fixtures/warning_node_modules/new-buffer-esm.mjs
Copy file name to clipboardExpand all lines: test/fixtures/warning_node_modules/new-buffer-esm.mjs+1Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file
test/fixtures/warning_node_modules/node_modules/new-buffer-cjs/index.js
Copy file name to clipboardExpand all lines: test/fixtures/warning_node_modules/node_modules/new-buffer-cjs/index.js+1Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file
test/fixtures/warning_node_modules/node_modules/new-buffer-cjs/package.json
Copy file name to clipboardExpand all lines: test/fixtures/warning_node_modules/node_modules/new-buffer-cjs/package.json+3Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file
test/fixtures/warning_node_modules/node_modules/new-buffer-esm/index.js
Copy file name to clipboardExpand all lines: test/fixtures/warning_node_modules/node_modules/new-buffer-esm/index.js+2Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file
test/fixtures/warning_node_modules/node_modules/new-buffer-esm/package.json
Copy file name to clipboardExpand all lines: test/fixtures/warning_node_modules/node_modules/new-buffer-esm/package.json+4Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file
test/parallel/test-buffer-constructor-node-modules.js
Copy file name to clipboard+48Lines changed: 48 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
0 commit comments