This repository was archived by the owner on Apr 16, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 19
Reinclude --loader
temporarily, moving new work to Phase3
#47
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,6 @@ | ||
// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/example-loader.mjs | ||
/* eslint-disable node-core/required-modules */ | ||
import assert from 'assert'; | ||
import ok from '../fixtures/es-modules/test-esm-ok.mjs'; | ||
|
||
assert(ok); |
This file contains hidden or 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,5 @@ | ||
// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/loader-with-dep.mjs | ||
/* eslint-disable node-core/required-modules */ | ||
import '../fixtures/es-modules/test-esm-ok.mjs'; | ||
|
||
// We just test that this module doesn't fail loading |
This file contains hidden or 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,12 @@ | ||
// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/loader-invalid-format.mjs | ||
/* eslint-disable node-core/required-modules */ | ||
import { expectsError, mustCall } from '../common/index.mjs'; | ||
import assert from 'assert'; | ||
|
||
import('../fixtures/es-modules/test-esm-ok.mjs') | ||
.then(assert.fail, expectsError({ | ||
code: 'ERR_INVALID_RETURN_PROPERTY_VALUE', | ||
message: 'Expected string to be returned for the "format" from the ' + | ||
'"loader resolve" function but got type undefined.' | ||
})) | ||
.then(mustCall()); |
This file contains hidden or 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,14 @@ | ||
// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/loader-invalid-url.mjs | ||
/* eslint-disable node-core/required-modules */ | ||
|
||
import { expectsError, mustCall } from '../common/index.mjs'; | ||
import assert from 'assert'; | ||
|
||
import('../fixtures/es-modules/test-esm-ok.mjs') | ||
.then(assert.fail, expectsError({ | ||
code: 'ERR_INVALID_RETURN_PROPERTY', | ||
message: 'Expected a valid url to be returned for the "url" from the ' + | ||
'"loader resolve" function but got ' + | ||
'../fixtures/es-modules/test-esm-ok.mjs.' | ||
})) | ||
.then(mustCall()); |
10 changes: 10 additions & 0 deletions
10
test/es-module/test-esm-loader-missing-dynamic-instantiate-hook.mjs
This file contains hidden or 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,10 @@ | ||
// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/missing-dynamic-instantiate-hook.mjs | ||
/* eslint-disable node-core/required-modules */ | ||
|
||
import { expectsError } from '../common/index.mjs'; | ||
|
||
import('test').catch(expectsError({ | ||
code: 'ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK', | ||
message: 'The ES Module loader may not return a format of \'dynamic\' ' + | ||
'when no dynamicInstantiate function was provided' | ||
})); |
This file contains hidden or 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,9 @@ | ||
// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/builtin-named-exports-loader.mjs | ||
/* eslint-disable node-core/required-modules */ | ||
import '../common/index.mjs'; | ||
import { readFile } from 'fs'; | ||
import assert from 'assert'; | ||
import ok from '../fixtures/es-modules/test-esm-ok.mjs'; | ||
|
||
assert(ok); | ||
assert(readFile); |
3 changes: 3 additions & 0 deletions
3
test/es-module/test-esm-preserve-symlinks-not-found-plain.mjs
This file contains hidden or 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,3 @@ | ||
// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/not-found-assert-loader.mjs | ||
/* eslint-disable node-core/required-modules */ | ||
import './not-found.js'; |
This file contains hidden or 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,3 @@ | ||
// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/not-found-assert-loader.mjs | ||
/* eslint-disable node-core/required-modules */ | ||
import './not-found.mjs'; |
This file contains hidden or 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,8 @@ | ||
// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/js-loader.mjs | ||
/* eslint-disable node-core/required-modules */ | ||
import { namedExport } from '../fixtures/es-module-loaders/js-as-esm.js'; | ||
import assert from 'assert'; | ||
import ok from '../fixtures/es-modules/test-esm-ok.mjs'; | ||
|
||
assert(ok); | ||
assert(namedExport); |
This file contains hidden or 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,11 @@ | ||
// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/loader-shared-dep.mjs | ||
/* eslint-disable node-core/required-modules */ | ||
import { createRequire } from '../common/index.mjs'; | ||
|
||
import assert from 'assert'; | ||
import '../fixtures/es-modules/test-esm-ok.mjs'; | ||
|
||
const require = createRequire(import.meta.url); | ||
const dep = require('../fixtures/es-module-loaders/loader-dep.js'); | ||
|
||
assert.strictEqual(dep.format, 'module'); |
This file contains hidden or 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,16 @@ | ||
// Flags: --experimental-modules | ||
/* eslint-disable node-core/required-modules */ | ||
|
||
import '../common/index.mjs'; | ||
import assert from 'assert'; | ||
|
||
async function doTest() { | ||
await assert.rejects( | ||
async () => { | ||
await import('../fixtures/es-module-loaders/throw-undefined.mjs'); | ||
}, | ||
(e) => e === undefined | ||
); | ||
} | ||
|
||
doTest(); |
29 changes: 29 additions & 0 deletions
29
test/fixtures/es-module-loaders/builtin-named-exports-loader.mjs
This file contains hidden or 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,29 @@ | ||
import module from 'module'; | ||
|
||
const builtins = new Set( | ||
Object.keys(process.binding('natives')).filter(str => | ||
/^(?!(?:internal|node|v8)\/)/.test(str)) | ||
); | ||
|
||
export function dynamicInstantiate(url) { | ||
const builtinInstance = module._load(url.substr(5)); | ||
const builtinExports = ['default', ...Object.keys(builtinInstance)]; | ||
return { | ||
exports: builtinExports, | ||
execute: exports => { | ||
for (let name of builtinExports) | ||
exports[name].set(builtinInstance[name]); | ||
exports.default.set(builtinInstance); | ||
} | ||
}; | ||
} | ||
|
||
export function resolve(specifier, base, defaultResolver) { | ||
if (builtins.has(specifier)) { | ||
return { | ||
url: `node:${specifier}`, | ||
format: 'dynamic' | ||
}; | ||
} | ||
return defaultResolver(specifier, base); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.