Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/commonjs/src/dynamic-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function getDynamicRequireModules(patterns, dynamicRequireRoot) {
const dynamicRequireModules = new Map();
const dirNames = new Set();
for (const pattern of !patterns || Array.isArray(patterns) ? patterns || [] : [patterns]) {
const isNegated = pattern.startsWith('!');
const isNegated = pattern[0] === '!';
const modifyMap = (targetPath, resolvedPath) =>
isNegated
? dynamicRequireModules.delete(targetPath)
Expand Down
2 changes: 1 addition & 1 deletion packages/commonjs/src/resolve-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default function getResolveId(extensions, isPossibleCjsId) {
}
}

if (importee.startsWith('\0')) {
if (importee[0] === '\0') {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/commonjs/src/resolve-require-sources.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export function getRequireResolver(extensions, detectCyclesAndConditional, curre
const requireTargets = await Promise.all(
sources.map(async ({ source, isConditional }) => {
// Never analyze or proxy internal modules
if (source.startsWith('\0')) {
if (source[0] === '\0') {
return { id: source, allowProxy: false };
}
currentlyResolvingForParent.add(source);
Expand Down
4 changes: 2 additions & 2 deletions packages/dynamic-import-vars/src/dynamic-import-to-glob.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ export function dynamicImportToGlob(node, sourceString) {

glob = glob.replace(/\*\*/g, '*');

if (glob.startsWith('*')) {
if (glob[0] === '*') {
throw new VariableDynamicImportError(
`invalid import "${sourceString}". It cannot be statically analyzed. Variable dynamic imports must start with ./ and be limited to a specific directory. ${example}`
);
}

if (glob.startsWith('/')) {
if (glob[0] === '/') {
throw new VariableDynamicImportError(
`invalid import "${sourceString}". Variable absolute imports are not supported, imports must start with ./ in the static part of the import. ${example}`
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function resolvePackageImports({
};

// Assert: specifier begins with "#".
if (!importSpecifier.startsWith('#')) {
if (importSpecifier[0] !== '#') {
throw new InvalidModuleSpecifierError(context, true, 'Invalid import specifier.');
}

Expand Down
4 changes: 2 additions & 2 deletions packages/node-resolve/src/package/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function isUrl(str: string) {
* Conditions is an export object where all keys are conditions like 'node' (aka do not with '.')
*/
export function isConditions(exports: any) {
return typeof exports === 'object' && Object.keys(exports).every((k) => !k.startsWith('.'));
return typeof exports === 'object' && Object.keys(exports).every((k) => k[0] !== '.');
}

/**
Expand All @@ -50,7 +50,7 @@ export function isMappings(exports: any) {
*/
export function isMixedExports(exports: Record<string, any>) {
const keys = Object.keys(exports);
return keys.some((k) => k.startsWith('.')) && keys.some((k) => !k.startsWith('.'));
return keys.some((k) => k[0] === '.') && keys.some((k) => k[0] !== '.');
}

export function createBaseErrorMsg(importSpecifier: string, importer: string) {
Expand Down
2 changes: 1 addition & 1 deletion packages/node-resolve/src/resolveImportSpecifiers.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async function resolveWithExportMap({
ignoreSideEffectsForRoot,
allowExportsFolderMapping
}) {
if (importSpecifier.startsWith('#')) {
if (importSpecifier[0] === '#') {
// this is a package internal import, resolve using package imports field
const resolveResult = await resolvePackageImports({
importSpecifier,
Expand Down
2 changes: 1 addition & 1 deletion packages/node-resolve/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { realpathSync } from './fs';

// returns the imported package name for bare module imports
export function getPackageName(id) {
if (id.startsWith('.') || id.startsWith('/')) {
if (id[0] === '.' || id[0] === '/') {
return null;
}

Expand Down
Loading