8000 Add node: for all internal modules · HowProgrammingWorks/Sandboxes@718bed2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 718bed2

Browse files
committed
Add node: for all internal modules
1 parent a097af8 commit 718bed2

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

JavaScript/application.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// of a sample application to be executed in the sandboxed context by
55
// another pice of code from `framework.js`. Read README.md for tasks.
66

7-
const fs = require('fs');
8-
const net = require('net');
7+
const fs = require('node:fs');
8+
const net = require('node:net');
99

1010
// Print from the global context of application module
1111
console.log('From application global context');

JavaScript/framework.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ const PARSING_TIMEOUT = 1000;
88
const EXECUTION_TIMEOUT = 5000;
99

1010
// The framework can require core libraries
11-
const fs = require('fs');
12-
const vm = require('vm');
13-
const timers = require('timers');
14-
const events = require('events');
11+
const fs = require('node:fs');
12+
const vm = require('node:vm');
13+
const timers = require('node:timers');
14+
const events = require('node:events');
1515

1616
// Create a hash and turn it into the sandboxed context which will be
1717
// the global context of an application
1818
const context = {
1919
module: {}, console,
2020
require: (name) => {
21-
if (name === 'fs') {
21+
if (name === 'fs' || name === 'node:fs') {
2222
console.log('Module fs is restricted');
2323
return null;
2424
}

0 commit comments

Comments
 (0)
0