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

unplugin-auto-import

Package Overview
Dependencies
Maintainers
2
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unplugin-auto-import - npm Package Compare versions

Comparing version 0.10.3 to 0.11.0

dist/chunk-A4AIXWZJ.cjs

74

dist/chunk-BQPAGBJJ.js

@@ -1,17 +0,17 @@

"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
import {
presets
} from "./chunk-JY76L5KG.js";
var _chunkJY76L5KGjs = require('./chunk-JY76L5KG.js');
// src/core/unplugin.ts
var _unplugin = require('unplugin');
import { createUnplugin } from "unplugin";
// src/core/ctx.ts
var _path = require('path');
var _fs = require('fs');
var _utils = require('@antfu/utils');
var _pluginutils = require('@rollup/pluginutils');
var _localpkg = require('local-pkg');
var _addons = require('unimport/addons');
var _unimport = require('unimport');
var _magicstring = require('magic-string'); var _magicstring2 = _interopRequireDefault(_magicstring);
import { dirname, isAbsolute, relative, resolve } from "path";
import { promises as fs } from "fs";
import { slash, throttle, toArray as toArray2 } from "@antfu/utils";
import { createFilter } from "@rollup/pluginutils";
import { isPackageExists } from "local-pkg";
import { vueTemplateAddon } from "unimport/addons";
import { createUnimport, scanDirExports } from "unimport";
import MagicString from "magic-string";

@@ -21,3 +21,3 @@ // src/core/eslintrc.ts

const eslintConfigs = { globals: {} };
imports.map((i) => _nullishCoalesce(i.as, () => ( i.name))).filter(Boolean).sort().forEach((name) => {
imports.map((i) => i.as ?? i.name).filter(Boolean).sort().forEach((name) => {
eslintConfigs.globals[name] = eslintrc.globalsPropValue || true;

@@ -30,3 +30,3 @@ });

// src/core/resolvers.ts
import { toArray } from "@antfu/utils";
function normalizeImport(info, name) {

@@ -79,3 +79,3 @@ if (typeof info === "string") {

if ("sideEffects" in matchedImport)
sideEffects.push(..._utils.toArray.call(void 0, matchedImport.sideEffects).map((i) => normalizeImport(i, "")));
sideEffects.push(...toArray(matchedImport.sideEffects).map((i) => normalizeImport(i, "")));
return;

@@ -87,3 +87,3 @@ }

if (resolved == null ? void 0 : resolved.sideEffects)
sideEffects.push(..._utils.toArray.call(void 0, resolved == null ? void 0 : resolved.sideEffects).map((i) => normalizeImport(i, "")));
sideEffects.push(...toArray(resolved == null ? void 0 : resolved.sideEffects).map((i) => normalizeImport(i, "")));
}));

@@ -110,5 +110,5 @@ if (dynamic.length) {

const {
dts: preferDTS = _localpkg.isPackageExists.call(void 0, "typescript")
dts: preferDTS = isPackageExists("typescript")
} = options;
const dirs = (_b = options.dirs) == null ? void 0 : _b.map((dir) => _path.resolve.call(void 0, root, dir));
const dirs = (_b = options.dirs) == null ? void 0 : _b.map((dir) => resolve(root, dir));
const eslintrc = options.eslintrc || {};

@@ -119,7 +119,7 @@ eslintrc.enabled = eslintrc.enabled === void 0 ? false : eslintrc.enabled;

const resolvers = options.resolvers ? [options.resolvers].flat(2) : [];
const unimport = _unimport.createUnimport.call(void 0, {
const unimport = createUnimport({
imports,
presets: [],
addons: [
...options.vueTemplate ? [_addons.vueTemplateAddon.call(void 0, )] : [],
...options.vueTemplate ? [vueTemplateAddon()] : [],
resolversAddon(resolvers),

@@ -136,10 +136,10 @@ {

});
const filter = _pluginutils.createFilter.call(void 0, options.include || [/\.[jt]sx?$/, /\.vue$/, /\.vue\?vue/, /\.svelte$/], options.exclude || [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/]);
const dts = preferDTS === false ? false : preferDTS === true ? _path.resolve.call(void 0, root, "auto-imports.d.ts") : _path.resolve.call(void 0, root, preferDTS);
const filter = createFilter(options.include || [/\.[jt]sx?$/, /\.vue$/, /\.vue\?vue/, /\.svelte$/], options.exclude || [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/]);
const dts = preferDTS === false ? false : preferDTS === true ? resolve(root, "auto-imports.d.ts") : resolve(root, preferDTS);
function generateDTS(file) {
const dir = _path.dirname.call(void 0, file);
const dir = dirname(file);
return unimport.generateTypeDeclarations({
resolvePath: (i) => {
if (i.from.startsWith(".") || _path.isAbsolute.call(void 0, i.from)) {
const related = _utils.slash.call(void 0, _path.relative.call(void 0, dir, i.from).replace(/\.ts$/, ""));
if (i.from.startsWith(".") || isAbsolute(i.from)) {
const related = slash(relative(dir, i.from).replace(/\.ts$/, ""));
return !related.startsWith(".") ? `./${related}` : related;

@@ -154,3 +154,3 @@ }

}
const writeConfigFilesThrottled = _utils.throttle.call(void 0, 500, false, writeConfigFiles);
const writeConfigFilesThrottled = throttle(500, false, writeConfigFiles);
let lastDTS;

@@ -164,3 +164,3 @@ let lastESLint;

lastDTS = content;
promises.push(_fs.promises.writeFile(dts, content, "utf-8"));
promises.push(fs.writeFile(dts, content, "utf-8"));
}

@@ -172,3 +172,3 @@ }

lastESLint = content;
promises.push(_fs.promises.writeFile(eslintrc.filepath, content, "utf-8"));
promises.push(fs.writeFile(eslintrc.filepath, content, "utf-8"));
}

@@ -181,3 +181,3 @@ }

await unimport.modifyDynamicImports(async (imports2) => {
const exports = await _unimport.scanDirExports.call(void 0, dirs);
const exports = await scanDirExports(dirs);
exports.forEach((i) => i.__source = "dir");

@@ -193,3 +193,3 @@ return [

async function transform(code, id) {
const s = new (0, _magicstring2.default)(code);
const s = new MagicString(code);
await unimport.injectImports(s, id);

@@ -220,7 +220,7 @@ if (!s.hasChanged())

const flat = {};
_utils.toArray.call(void 0, map).forEach((definition) => {
toArray2(map).forEach((definition) => {
if (typeof definition === "string") {
if (!_chunkJY76L5KGjs.presets[definition])
if (!presets[definition])
throw new Error(`[auto-import] preset ${definition} not found`);
const preset = _chunkJY76L5KGjs.presets[definition];
const preset = presets[definition];
definition = typeof preset === "function" ? preset() : preset;

@@ -253,3 +253,3 @@ }

// src/core/unplugin.ts
var unplugin_default = _unplugin.createUnplugin.call(void 0, (options) => {
var unplugin_default = createUnplugin((options) => {
let ctx = createContext(options);

@@ -287,4 +287,4 @@ return {

exports.unplugin_default = unplugin_default;
export {
unplugin_default
};

@@ -1,4 +0,4 @@

"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/presets/ahooks.ts
var _fs = require('fs');
var _localpkg = require('local-pkg');
// src/presets/ahooks.ts
import { readFileSync } from "fs";
import { resolveModule } from "local-pkg";
var _cache;

@@ -9,4 +9,4 @@ var ahooks_default = () => {

try {
const path = _localpkg.resolveModule.call(void 0, "ahooks/metadata.json");
indexesJson = JSON.parse(_fs.readFileSync.call(void 0, path, "utf-8"));
const path = resolveModule("ahooks/metadata.json");
indexesJson = JSON.parse(readFileSync(path, "utf-8"));
} catch (error) {

@@ -374,4 +374,4 @@ console.error(error);

// src/presets/vueuse-core.ts
import { readFileSync as readFileSync2 } from "fs";
import { resolveModule as resolveModule2 } from "local-pkg";
var _cache2;

@@ -383,5 +383,5 @@ var vueuse_core_default = () => {

try {
const corePath = _localpkg.resolveModule.call(void 0, "@vueuse/core") || process.cwd();
const path = _localpkg.resolveModule.call(void 0, "@vueuse/core/indexes.json") || _localpkg.resolveModule.call(void 0, "@vueuse/metadata/index.json") || _localpkg.resolveModule.call(void 0, "@vueuse/metadata/index.json", { paths: [corePath] });
indexesJson = JSON.parse(_fs.readFileSync.call(void 0, path, "utf-8"));
const corePath = resolveModule2("@vueuse/core") || process.cwd();
const path = resolveModule2("@vueuse/core/indexes.json") || resolveModule2("@vueuse/metadata/index.json") || resolveModule2("@vueuse/metadata/index.json", { paths: [corePath] });
indexesJson = JSON.parse(readFileSync2(path, "utf-8"));
} catch (error) {

@@ -608,4 +608,4 @@ console.error(error);

// src/presets/vueuse-math.ts
import { readFileSync as readFileSync3 } from "fs";
import { resolveModule as resolveModule3 } from "local-pkg";
var _cache3;

@@ -616,5 +616,5 @@ var vueuse_math_default = () => {

try {
const corePath = _localpkg.resolveModule.call(void 0, "@vueuse/core") || process.cwd();
const path = _localpkg.resolveModule.call(void 0, "@vueuse/metadata/index.json") || _localpkg.resolveModule.call(void 0, "@vueuse/metadata/index.json", { paths: [corePath] });
indexesJson = JSON.parse(_fs.readFileSync.call(void 0, path, "utf-8"));
const corePath = resolveModule3("@vueuse/core") || process.cwd();
const path = resolveModule3("@vueuse/metadata/index.json") || resolveModule3("@vueuse/metadata/index.json", { paths: [corePath] });
indexesJson = JSON.parse(readFileSync3(path, "utf-8"));
} catch (error) {

@@ -672,4 +672,4 @@ console.error(error);

exports.presets = presets;
export {
presets
};

@@ -1,11 +0,10 @@

"use strict";Object.defineProperty(exports, "__esModule", {value: true});
import {
unplugin_default
} from "./chunk-BQPAGBJJ.js";
import "./chunk-JY76L5KG.js";
var _chunkBQPAGBJJjs = require('./chunk-BQPAGBJJ.js');
require('./chunk-JY76L5KG.js');
// src/esbuild.ts
var esbuild_default = _chunkBQPAGBJJjs.unplugin_default.esbuild;
module.exports = esbuild_default;
exports.default = module.exports;
var esbuild_default = unplugin_default.esbuild;
export {
esbuild_default as default
};

@@ -1,7 +0,7 @@

"use strict";Object.defineProperty(exports, "__esModule", {value: true});
var _chunkBQPAGBJJjs = require('./chunk-BQPAGBJJ.js');
require('./chunk-JY76L5KG.js');
exports.default = _chunkBQPAGBJJjs.unplugin_default;
import {
unplugin_default
} from "./chunk-BQPAGBJJ.js";
import "./chunk-JY76L5KG.js";
export {
unplugin_default as default
};

@@ -1,6 +0,6 @@

"use strict";Object.defineProperty(exports, "__esModule", {value: true});
import {
unplugin_default
} from "./chunk-BQPAGBJJ.js";
import "./chunk-JY76L5KG.js";
var _chunkBQPAGBJJjs = require('./chunk-BQPAGBJJ.js');
require('./chunk-JY76L5KG.js');
// src/nuxt.ts

@@ -11,12 +11,11 @@ function nuxt_default(options) {

config.plugins = config.plugins || [];
config.plugins.unshift(_chunkBQPAGBJJjs.unplugin_default.webpack(options));
config.plugins.unshift(unplugin_default.webpack(options));
});
this.nuxt.hook("vite:extend", async (vite) => {
vite.config.plugins = vite.config.plugins || [];
vite.config.plugins.push(_chunkBQPAGBJJjs.unplugin_default.vite(options));
vite.config.plugins.push(unplugin_default.vite(options));
});
}
module.exports = nuxt_default;
exports.default = module.exports;
export {
nuxt_default as default
};

@@ -1,11 +0,10 @@

"use strict";Object.defineProperty(exports, "__esModule", {value: true});
import {
unplugin_default
} from "./chunk-BQPAGBJJ.js";
import "./chunk-JY76L5KG.js";
var _chunkBQPAGBJJjs = require('./chunk-BQPAGBJJ.js');
require('./chunk-JY76L5KG.js');
// src/rollup.ts
var rollup_default = _chunkBQPAGBJJjs.unplugin_default.rollup;
module.exports = rollup_default;
exports.default = module.exports;
var rollup_default = unplugin_default.rollup;
export {
rollup_default as default
};

@@ -1,2 +0,1 @@

"use strict";require('./chunk-JY76L5KG.js');
exports.default = module.exports;
import "./chunk-JY76L5KG.js";

@@ -1,11 +0,10 @@

"use strict";Object.defineProperty(exports, "__esModule", {value: true});
import {
unplugin_default
} from "./chunk-BQPAGBJJ.js";
import "./chunk-JY76L5KG.js";
var _chunkBQPAGBJJjs = require('./chunk-BQPAGBJJ.js');
require('./chunk-JY76L5KG.js');
// src/vite.ts
var vite_default = _chunkBQPAGBJJjs.unplugin_default.vite;
module.exports = vite_default;
exports.default = module.exports;
var vite_default = unplugin_default.vite;
export {
vite_default as default
};

@@ -1,11 +0,10 @@

"use strict";Object.defineProperty(exports, "__esModule", {value: true});
import {
unplugin_default
} from "./chunk-BQPAGBJJ.js";
import "./chunk-JY76L5KG.js";
var _chunkBQPAGBJJjs = require('./chunk-BQPAGBJJ.js');
require('./chunk-JY76L5KG.js');
// src/webpack.ts
var webpack_default = _chunkBQPAGBJJjs.unplugin_default.webpack;
module.exports = webpack_default;
exports.default = module.exports;
var webpack_default = unplugin_default.webpack;
export {
webpack_default as default
};
{
"name": "unplugin-auto-import",
"version": "0.10.3",
"type": "module",
"version": "0.11.0",
"packageManager": "pnpm@7.1.1",

@@ -29,4 +30,4 @@ "description": "Register global imports on demand for Vite and Webpack",

"types": "./dist/index.d.ts",
"require": "./dist/index.js",
"import": "./dist/index.mjs"
"require": "./dist/index.cjs",
"import": "./dist/index.js"
},

@@ -36,33 +37,33 @@ "./*": "./*",

"types": "./dist/nuxt.d.ts",
"require": "./dist/nuxt.js",
"import": "./dist/nuxt.mjs"
"require": "./dist/nuxt.cjs",
"import": "./dist/nuxt.js"
},
"./rollup": {
"types": "./dist/rollup.d.ts",
"require": "./dist/rollup.js",
"import": "./dist/rollup.mjs"
"require": "./dist/rollup.cjs",
"import": "./dist/rollup.js"
},
"./types": {
"types": "./dist/types.d.ts",
"require": "./dist/types.js",
"import": "./dist/types.mjs"
"require": "./dist/types.cjs",
"import": "./dist/types.js"
},
"./vite": {
"types": "./dist/vite.d.ts",
"require": "./dist/vite.js",
"import": "./dist/vite.mjs"
"require": "./dist/vite.cjs",
"import": "./dist/vite.js"
},
"./webpack": {
"types": "./dist/webpack.d.ts",
"require": "./dist/webpack.js",
"import": "./dist/webpack.mjs"
"require": "./dist/webpack.cjs",
"import": "./dist/webpack.js"
},
"./esbuild": {
"types": "./dist/esbuild.d.ts",
"require": "./dist/esbuild.js",
"import": "./dist/esbuild.mjs"
"require": "./dist/esbuild.cjs",
"import": "./dist/esbuild.js"
}
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"main": "dist/index.cjs",
"module": "dist/index.js",
"types": "dist/index.d.ts",

@@ -96,4 +97,4 @@ "typesVersions": {

"magic-string": "^0.26.2",
"unimport": "^0.6.4",
"unplugin": "^0.8.0"
"unimport": "^0.6.5",
"unplugin": "^0.8.1"
},

@@ -103,14 +104,14 @@ "devDependencies": {

"@antfu/ni": "^0.17.2",
"@types/node": "^18.6.1",
"@types/node": "^18.6.3",
"@types/resolve": "^1.20.2",
"@vueuse/metadata": "^9.0.0",
"@vueuse/metadata": "^9.1.0",
"bumpp": "^8.2.1",
"eslint": "^8.20.0",
"eslint": "^8.21.0",
"esno": "^0.16.3",
"fast-glob": "^3.2.11",
"rollup": "^2.77.2",
"tsup": "^6.2.0",
"tsup": "^6.2.1",
"typescript": "^4.7.4",
"vite": "^3.0.3",
"vitest": "^0.19.1",
"vite": "^3.0.4",
"vitest": "^0.20.3",
"webpack": "^5.74.0"

@@ -117,0 +118,0 @@ },

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