vite-plugin-dynamic-import
Advanced tools
Comparing version 0.8.1 to 0.8.2
@@ -80,3 +80,3 @@ "use strict"; | ||
return; | ||
const importeeMappings = listImporteeMappings(glob, globExtensions, alias ? alias.files : files); | ||
const importeeMappings = listImporteeMappings(glob, globExtensions, files, alias); | ||
const importRuntime = (0, dynamic_import_helper_1.generateDynamicImportRuntime)(importeeMappings, dynamicImportIndex++); | ||
@@ -176,21 +176,23 @@ dynamicImportRecords.push({ ...dyRecord, importRuntime }); | ||
} | ||
function listImporteeMappings(glob, extensions, importeeList) { | ||
function listImporteeMappings(glob, extensions, importeeList, alias) { | ||
const hasExtension = extensions.some(ext => glob.endsWith(ext)); | ||
return importeeList.reduce((memo, importee) => { | ||
return importeeList.reduce((memo, importee, idx) => { | ||
const realFilepath = importee; | ||
importee = alias ? alias.files[idx] : importee; | ||
if (hasExtension) { | ||
return Object.assign(memo, { [importee]: [importee] }); | ||
return Object.assign(memo, { [realFilepath]: [importee] }); | ||
} | ||
const ext = extensions.find(ext => importee.endsWith(ext)); | ||
const list = [ | ||
// foo/index | ||
importee.replace(ext, ''), | ||
// foo/index.js | ||
importee, | ||
// foo/index | ||
importee.replace(ext, ''), | ||
]; | ||
if (importee.endsWith('index' + ext)) { | ||
// foo | ||
list.push(importee.replace('/index' + ext, '')); | ||
list.unshift(importee.replace('/index' + ext, '')); | ||
} | ||
return Object.assign(memo, { [importee]: list }); | ||
return Object.assign(memo, { [realFilepath]: list }); | ||
}, {}); | ||
} |
{ | ||
"name": "vite-plugin-dynamic-import", | ||
"version": "0.8.1", | ||
"version": "0.8.2", | ||
"description": "Enhance Vite builtin dynamic import", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -106,3 +106,4 @@ import path from 'path' | ||
globExtensions, | ||
alias ? alias.files : files, | ||
files, | ||
alias, | ||
) | ||
@@ -260,7 +261,10 @@ | ||
importeeList: string[], | ||
alias?: GlobHasFiles['alias'], | ||
) { | ||
const hasExtension = extensions.some(ext => glob.endsWith(ext)) | ||
return importeeList.reduce((memo, importee) => { | ||
return importeeList.reduce((memo, importee, idx) => { | ||
const realFilepath = importee | ||
importee = alias ? alias.files[idx] : importee | ||
if (hasExtension) { | ||
return Object.assign(memo, { [importee]: [importee] }) | ||
return Object.assign(memo, { [realFilepath]: [importee] }) | ||
} | ||
@@ -270,13 +274,13 @@ | ||
const list = [ | ||
// foo/index | ||
importee.replace(ext, ''), | ||
// foo/index.js | ||
importee, | ||
// foo/index | ||
importee.replace(ext, ''), | ||
] | ||
if (importee.endsWith('index' + ext)) { | ||
// foo | ||
list.push(importee.replace('/index' + ext, '')) | ||
list.unshift(importee.replace('/index' + ext, '')) | ||
} | ||
return Object.assign(memo, { [importee]: list }) | ||
return Object.assign(memo, { [realFilepath]: list }) | ||
}, {} as Record</* localFilename */string, /* Array<possible importee> */string[]>) | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51780
1177