-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vm: add code cache support for SourceTextModule
PR-URL: #31278 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
- Loading branch information
1 parent
c252356
commit 27564a4
Showing
8 changed files
with
162 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
|
||
// Flags: --experimental-vm-modules | ||
|
||
require('../common'); | ||
|
||
const assert = require('assert'); | ||
const { SourceTextModule } = require('vm'); | ||
|
||
{ | ||
const m = new SourceTextModule('const a = 1'); | ||
const cachedData = m.createCachedData(); | ||
|
||
new SourceTextModule('const a = 1', { cachedData }); | ||
|
||
assert.throws(() => { | ||
new SourceTextModule('differentSource', { cachedData }); | ||
}, { | ||
code: 'ERR_VM_MODULE_CACHED_DATA_REJECTED', | ||
}); | ||
} | ||
|
||
assert.rejects(async () => { | ||
const m = new SourceTextModule('const a = 1'); | ||
await m.link(() => {}); | ||
m.evaluate(); | ||
m.createCachedData(); | ||
}, { | ||
code: 'ERR_VM_MODULE_CANNOT_CREATE_CACHED_DATA', | ||
}); |