Skip to content

Commit

Permalink
Cosmetic edits
Browse files Browse the repository at this point in the history
  • Loading branch information
Septh committed Dec 15, 2024
1 parent fb47ce0 commit 607ed68
Showing 1 changed file with 24 additions and 26 deletions.
50 changes: 24 additions & 26 deletions source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,35 +232,33 @@ function nodeExternals(options: ExternalsOptions = {}): Plugin {
include.push(new RegExp('^(?:' + names.join('|') + ')(?:/.+)?$'))
},

resolveId: {
async handler(specifier, importer, { isEntry }) {
if (
isEntry // Ignore entry points
|| /^(?:\0|\.{1,2}\/)/.test(specifier) // Ignore virtual modules and relative imports
|| path.isAbsolute(specifier) // Ignore already resolved ids
) {
return null
}
resolveId(specifier, _, { isEntry }) {
if (
isEntry // Ignore entry points
|| /^(?:\0|\.{1,2}\/)/.test(specifier) // Ignore virtual modules and relative imports
|| path.isAbsolute(specifier) // Ignore already resolved ids
) {
return null
}

// Handle node builtins.
if (isBuiltin(specifier)) {
const stripped = specifier.replace(/^node:/, '')
return {
id: config.builtinsPrefix === 'ignore'
? specifier
: config.builtinsPrefix === 'add' || !isBuiltin(stripped)
? 'node:' + stripped
: stripped,
external: (config.builtins || isIncluded(specifier)) && !isExcluded(specifier),
moduleSideEffects: false
}
// Handle node builtins.
if (isBuiltin(specifier)) {
const stripped = specifier.replace(/^node:/, '')
return {
id: config.builtinsPrefix === 'ignore'
? specifier
: config.builtinsPrefix === 'add' || !isBuiltin(stripped)
? 'node:' + stripped
: stripped,
external: (config.builtins || isIncluded(specifier)) && !isExcluded(specifier),
moduleSideEffects: false
}

// Handle npm dependencies.
return isIncluded(specifier) && !isExcluded(specifier)
? false // external
: null // normal handling
}

// Handle npm dependencies.
return isIncluded(specifier) && !isExcluded(specifier)
? false // external
: null // normal handling
}
} as ViteCompatiblePlugin
}
Expand Down

0 comments on commit 607ed68

Please sign in to comment.