Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vite-plugin-dynamic-import

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-dynamic-import - npm Package Compare versions

Comparing version 0.8.1 to 0.8.2

18

dist/index.js

@@ -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[]>)
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc