fix: no need to append `.js` to import for external packages

This commit is contained in:
Franck Royer 2022-07-26 15:03:19 +10:00 committed by fryorcraken.eth
parent 338e3c9964
commit c4f1d90c7b
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 2 additions and 2 deletions

View File

@ -3,7 +3,7 @@ import fs from "fs";
const START_PATH = path.join(process.cwd(), "dist/esm"); const START_PATH = path.join(process.cwd(), "dist/esm");
const IMPORT_REGEXP = const IMPORT_REGEXP =
/^((import|export) [^';]* from "(@[^";]+\/)?([^@";]*\/[^";]*)[^";]*)"/g; /^((import|export) [^';]* from "(\.[^@";]*\/[^";]*)[^";]*)"/g;
const JUST_ADD_AN_EXTENSION = '$1.js"'; const JUST_ADD_AN_EXTENSION = '$1.js"';
const ADD_INDEX_FILE = '$1/index.js"'; const ADD_INDEX_FILE = '$1/index.js"';
const JS_EXT = ".js"; const JS_EXT = ".js";
@ -36,7 +36,7 @@ function fixImportsAtFile(filePath) {
} }
const [_, importPath] = l.split(`"`); const [_, importPath] = l.split(`"`);
let exists = true; let exists;
let fullPath; let fullPath;
if (importPath.startsWith(".")) { if (importPath.startsWith(".")) {
fullPath = path.join(filePath, "..", importPath); fullPath = path.join(filePath, "..", importPath);