"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createFile = exports.ensureDottedRelative = exports.isNodeModule = exports.nodeModuleGlobs = exports.extraGlobs = exports.hasModuleGlobs = exports.isScript = void 0; const path_1 = require("path"); const esmRegex = /(^\s*|[}\);\n]\s*)(import\s*(['"]|(\*\s+as\s+)?(?!type)([^"'\(\)\n; ]+)\s*from\s*['"]|\{)|export\s+\*\s+from\s+["']|export\s*(\{|default|function|class|var|const|let|async\s+function))/, moduleGlob = ['**/*', '!node_modules', '!test', '!**/*.d.ts']; function isScript(code) { return !Boolean(code.match(esmRegex)); } exports.isScript = isScript; function hasModuleGlobs(file) { return nodeModuleGlobs(file) !== moduleGlob; } exports.hasModuleGlobs = hasModuleGlobs; function extraGlobs(file) { var _a, _b, _c, _d; const globs = []; return globs .concat(...[((_b = (_a = file.package) === null || _a === void 0 ? void 0 : _a.pkg) === null || _b === void 0 ? void 0 : _b.scripts) || []]) .concat(...[((_d = (_c = file.package) === null || _c === void 0 ? void 0 : _c.pkg) === null || _d === void 0 ? void 0 : _d.assets) || []]); } exports.extraGlobs = extraGlobs; function nodeModuleGlobs(file, useDefault = true) { var _a; const normalGlobs = [].concat(...(((_a = file.package) === null || _a === void 0 ? void 0 : _a.files) || [])); if (useDefault && !normalGlobs.length) { return moduleGlob; } return normalGlobs; } exports.nodeModuleGlobs = nodeModuleGlobs; const notNodeModule = /^\.|^\//; function isNodeModule(request) { return !notNodeModule.test(request); } exports.isNodeModule = isNodeModule; function ensureDottedRelative(from, to) { let rel = path_1.relative(from, to); if (!rel.startsWith('.' + path_1.sep)) { rel = './' + rel; } return rel.split(path_1.sep).join('/'); } exports.ensureDottedRelative = ensureDottedRelative; function createFile(absPath) { return { size: 0, deps: {}, absPath, moduleType: 'commonjs', contents: null, variableImports: false, }; } exports.createFile = createFile; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3Vy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