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
2
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 1.4.1 to 1.5.0

2

dist/index.d.ts

@@ -53,5 +53,5 @@ import type { Plugin } from 'vite';

* ↓
* import('@/viewsfoo.js')
* import('@/views/foo.js')
*/
normally?: string;
} | undefined>;

@@ -8,2 +8,3 @@ "use strict";

const fastGlob = require("fast-glob");
const MagicString = require("magic-string");
const os = require("node:os");

@@ -26,37 +27,2 @@ const DEFAULT_EXTENSIONS = [

}
class MagicString {
constructor(str) {
this.str = str;
this.starts = "";
this.ends = "";
}
append(content) {
this.ends += content;
return this;
}
prepend(content) {
this.starts = content + this.starts;
return this;
}
overwrite(start, end, content) {
if (end < start) {
throw new Error(`"end" con't be less than "start".`);
}
if (!this.overwrites) {
this.overwrites = [];
}
this.overwrites.push({ loc: [start, end], content });
return this;
}
toString() {
let str = this.str;
if (this.overwrites) {
const arr = [...this.overwrites].sort((a, b) => b.loc[0] - a.loc[0]);
for (const { loc: [start, end], content } of arr) {
str = str.slice(0, start) + content + str.slice(end);
}
}
return this.starts + str + this.ends;
}
}
function relativeify(relativePath) {

@@ -367,3 +333,3 @@ if (relativePath === "") {

}
const contents = await transformDynamicImport({
const result = await transformDynamicImport({
options,

@@ -375,5 +341,5 @@ code,

});
if (contents != null) {
if (result != null) {
return {
contents,
contents: result.code,
loader: id.slice(id.lastIndexOf(".") + 1)

@@ -499,4 +465,8 @@ };

}
const str = ms.toString();
return str !== code ? str : null;
if (ms.hasChanged()) {
return {
code: ms.toString(),
map: ms.generateMap({ hires: true, source: id })
};
}
}

@@ -503,0 +473,0 @@ async function globFiles({

{
"name": "vite-plugin-dynamic-import",
"version": "1.4.1",
"version": "1.5.0",
"description": "Enhance Vite builtin dynamic import",

@@ -31,3 +31,4 @@ "main": "./dist/index.js",

"es-module-lexer": "^1.2.1",
"fast-glob": "^3.2.12"
"fast-glob": "^3.2.12",
"magic-string": "^0.30.1"
},

@@ -34,0 +35,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

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