Skip to content
Permalink
Browse files

module: 12.x self resolve flag as experimental modules

PR-URL: #31757
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
  • Loading branch information
guybedford authored and MylesBorins committed Feb 12, 2020
1 parent 7a5954e commit f0b2d875d96d942d6d22612986dceb225317fede
Showing with 17 additions and 0 deletions.
  1. +1 −0 lib/internal/modules/cjs/loader.js
  2. +16 −0 test/es-module/test-esm-flagged-self.js
@@ -432,6 +432,7 @@ function resolveBasePath(basePath, exts, isMain, trailingSlash, request) {
}

function trySelf(parentPath, isMain, request) {
if (!experimentalModules) return false;
const { data: pkg, path: basePath } = readPackageScope(parentPath) || {};
if (!pkg || pkg.exports === undefined) return false;
if (typeof pkg.name !== 'string') return false;
@@ -0,0 +1,16 @@
'use strict';

require('../common');
const assert = require('assert');
const path = require('path');
const { createRequireFromPath } = require('module');

const fixturesRequire =
createRequireFromPath(path.resolve(__dirname, '../fixtures/_'));

try {
fixturesRequire('pkgexports/resolve-self');
assert(false);
} catch (e) {
assert.strictEqual(e.code, 'MODULE_NOT_FOUND');
}

0 comments on commit f0b2d87

Please sign in to comment.
You can’t perform that action at this time.