mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
module: fix Windows folder exports deprecation warning
PR-URL: https://github.com/nodejs/node/pull/36859 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
This commit is contained in:
1 parent
ec794f9796
commit
2e909c4fcc
6 files changed
+21
-5
No files matched your search
@@ -65,12 +65,11 @@ const emittedPackageWarnings = new SafeSet();
|
||||
function emitFolderMapDeprecation(match, pjsonUrl, isExports, base) {
|
||||
const pjsonPath = fileURLToPath(pjsonUrl);
|
||||
if (!pendingDeprecation) {
|
||||
const nodeModulesIndex = StringPrototypeLastIndexOf(pjsonPath,
|
||||
'/node_modules/');
|
||||
const nodeModulesIndex =
|
||||
StringPrototypeLastIndexOf(pjsonPath, sep + 'node_modules' + sep);
|
||||
if (nodeModulesIndex !== -1) {
|
||||
const afterNodeModulesPath = StringPrototypeSlice(pjsonPath,
|
||||
nodeModulesIndex + 14,
|
||||
-13);
|
||||
const afterNodeModulesPath =
|
||||
StringPrototypeSlice(pjsonPath, nodeModulesIndex + 14, -13);
|
||||
try {
|
||||
const { packageSubpath } = parsePackageName(afterNodeModulesPath);
|
||||
if (packageSubpath === '.')
|
||||
|
||||
@@ -6,6 +6,9 @@ import { pathToFileURL } from 'url';
|
||||
const selfDeprecatedFolders =
|
||||
fixtures.path('/es-modules/self-deprecated-folders/main.js');
|
||||
|
||||
const deprecatedFoldersIgnore =
|
||||
fixtures.path('/es-modules/deprecated-folders-ignore/main.js');
|
||||
|
||||
let curWarning = 0;
|
||||
const expectedWarnings = [
|
||||
'"./" in the "exports" field',
|
||||
@@ -18,5 +21,6 @@ process.addListener('warning', mustCall((warning) => {
|
||||
|
||||
(async () => {
|
||||
await import(pathToFileURL(selfDeprecatedFolders));
|
||||
await import(pathToFileURL(deprecatedFoldersIgnore));
|
||||
})()
|
||||
.catch((err) => console.error(err));
|
||||
@@ -0,0 +1 @@
|
||||
import 'pkg/folder/m.js';
|
||||
+1
@@ -0,0 +1 @@
|
||||
export default null;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"exports": {
|
||||
"./folder/": "./"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user