summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2019-11-23 00:45:10 -0500
committerBenjamin Coe <bencoe@google.com>2019-12-06 17:55:02 -0800
commit4ec02d5afdad4610b59fbc22ff2279e35120294e (patch)
tree5a40b1fa0edbe6a21b0615c9502e3cd9c1b5cc00 /test
parent5360dd151da9d8b1c97785a0e394cc731af31f69 (diff)
downloadandroid-node-v8-4ec02d5afdad4610b59fbc22ff2279e35120294e.tar.gz
android-node-v8-4ec02d5afdad4610b59fbc22ff2279e35120294e.tar.bz2
android-node-v8-4ec02d5afdad4610b59fbc22ff2279e35120294e.zip
module: fix dynamic import from eval
This allows dynamic import to work from CLI `--eval` with or without `--input-type=module`. Fixes: https://github.com/nodejs/node/issues/30591 PR-URL: https://github.com/nodejs/node/pull/30624 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yorkie Liu <yorkiefixer@gmail.com> Reviewed-By: Ben Coe <bencoe@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-cli-eval.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/parallel/test-cli-eval.js b/test/parallel/test-cli-eval.js
index 2cece62a43..65d3164205 100644
--- a/test/parallel/test-cli-eval.js
+++ b/test/parallel/test-cli-eval.js
@@ -283,3 +283,23 @@ child.exec(
assert.ifError(err);
assert.strictEqual(stdout, '.mjs file\n');
}));
+
+
+// Assert that packages can be dynamic imported initial cwd-relative with --eval
+child.exec(
+ `${nodejs} ${execOptions} ` +
+ '--eval "process.chdir(\'..\');' +
+ 'import(\'./test/fixtures/es-modules/mjs-file.mjs\')"',
+ common.mustCall((err, stdout) => {
+ assert.ifError(err);
+ assert.strictEqual(stdout, '.mjs file\n');
+ }));
+
+child.exec(
+ `${nodejs} ` +
+ '--eval "process.chdir(\'..\');' +
+ 'import(\'./test/fixtures/es-modules/mjs-file.mjs\')"',
+ common.mustCall((err, stdout) => {
+ assert.ifError(err);
+ assert.strictEqual(stdout, '.mjs file\n');
+ }));