New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@brillout/vite-plugin-server-entry

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brillout/vite-plugin-server-entry - npm Package Compare versions

Comparing version 0.4.8 to 0.4.9

5

dist/importServerEntry/debugLogsRuntime.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.debugLogsRuntimePost = exports.debugLogsRuntimePre = void 0;
exports.debugLogsRuntimePre = debugLogsRuntimePre;
exports.debugLogsRuntimePost = debugLogsRuntimePost;
const utils_1 = require("../shared/utils");

@@ -46,3 +47,2 @@ const debug_1 = require("../shared/debug");

}
exports.debugLogsRuntimePre = debugLogsRuntimePre;
function debugLogsRuntimePost({ success, requireError, outDir, isOutsideOfCwd }) {

@@ -57,2 +57,1 @@ if (!debug_1.DEBUG)

}
exports.debugLogsRuntimePost = debugLogsRuntimePost;

17

dist/importServerEntry/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.importServerEntry = void 0;
exports.importServerEntry = importServerEntry;
const utils_1 = require("./utils");
const import_1 = require("@brillout/import");
const debugLogsRuntime_1 = require("./debugLogsRuntime");
const serverEntryImportPromise_1 = require("../shared/serverEntryImportPromise");
const serverEntryFileNameBase_1 = require("../shared/serverEntryFileNameBase");

@@ -13,3 +12,3 @@ const debug_1 = require("../shared/debug");

(0, debugLogsRuntime_1.debugLogsRuntimePre)(autoImporter);
(0, utils_1.assertUsage)(autoImporter.status !== 'DISABLED', "As a library author, make sure your library doesn't call importServerEntry() when using `inject: true`");
(0, utils_1.assertUsage)(autoImporter.status !== 'DISABLED_BY_INJECT', "As a library author, make sure your library doesn't call importServerEntry() when using `inject: true`");
let success = false;

@@ -21,3 +20,2 @@ let requireError;

await autoImporter.loadServerEntry();
await globalThis[serverEntryImportPromise_1.serverEntryImportPromise];
success = true;

@@ -38,11 +36,2 @@ }

}
else {
(0, utils_1.assert)(
// Yarn PnP
autoImporter.status === 'UNSET' ||
// Build was aborted
autoImporter.status === 'BUILDING' ||
// User sets config.vitePluginServerEntry._testCrawler
autoImporter.status === 'TEST_CRAWLER');
}
if (!success) {

@@ -56,3 +45,2 @@ success = await crawlServerEntryFileWithNodeJs(outDir);

}
exports.importServerEntry = importServerEntry;
// dist/server/entry.js may not belong to process.cwd() if e.g. Vike is linked => autoImporter.js can potentially be shared between multiple projects

@@ -142,3 +130,2 @@ function isServerEntryOutsideOfCwd(paths) {

await (0, import_1.import_)(serverEntryFilePath);
await globalThis[serverEntryImportPromise_1.serverEntryImportPromise];
return true;

@@ -145,0 +132,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.debugLogsBuildtime = void 0;
exports.debugLogsBuildtime = debugLogsBuildtime;
const debug_1 = require("../shared/debug");

@@ -19,2 +19,1 @@ function debugLogsBuildtime({ disabled, paths }) {

}
exports.debugLogsBuildtime = debugLogsBuildtime;
export { serverEntryPlugin };
export { findServerEntry };
declare type PluginConfigProvidedByLibrary = {
export type { ConfigVitePluginServerEntry };
type PluginConfigProvidedByLibrary = {
getImporterCode: () => string;
libraryName: string;
inject?: boolean;
inject?: boolean | string[];
};
type PluginConfigProvidedByUser = {
autoImport?: boolean;
inject?: boolean | string[];
};
type ConfigVitePluginServerEntry = {
vitePluginServerEntry?: PluginConfigProvidedByUser;
};
/**

@@ -16,5 +24,5 @@ * This plugin does two things:

declare function serverEntryPlugin(pluginConfigProvidedByLibrary: PluginConfigProvidedByLibrary): Plugin_[];
declare type Plugin_ = any;
type Plugin_ = any;
declare function findServerEntry<OutputBundle extends Record<string, {
name: string | undefined;
}>>(bundle: OutputBundle): OutputBundle[string];

@@ -6,7 +6,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.findServerEntry = exports.serverEntryPlugin = void 0;
exports.serverEntryPlugin = serverEntryPlugin;
exports.findServerEntry = findServerEntry;
const utils_1 = require("./utils");
const path_1 = __importDefault(require("path"));
const fs_1 = require("fs");
const serverEntryImportPromise_1 = require("../shared/serverEntryImportPromise");
const serverEntryFileNameBase_1 = require("../shared/serverEntryFileNameBase");

@@ -19,3 +19,4 @@ const debugLogsBuildTime_1 = require("./debugLogsBuildTime");

const virtualIdPrefix = '\0';
const apiVersion = 4;
// Using the semver major to determine compatible versions is a much inferior solution. Because, for example, when the user updates Vike > @brillout/vite-plugin-server-entry from version 0.4.8 (`apiVersion===4`) to 0.4.10 (`apiVersion===5`) then things just works because Telefunc > @brillout/vite-plugin-server-entry also updates to `0.4.10`. On the other hand, when the user updates Vike > @brillout/vite-plugin-server-entry to 0.5.0 then this won't update Telefunc > @brillout/vite-plugin-server-entry which is stuck to 0.4.x and the user is forced to update Telefunc.
const apiVersion = 5;
/**

@@ -31,3 +32,3 @@ * This plugin does two things:

let config;
let serverIndexFilePath;
let injectEntries;
let library;

@@ -50,2 +51,3 @@ let skip;

assertApiVersions(config, pluginConfigProvidedByLibrary.libraryName);
applyPluginConfigProvidedByUser(config);
if (!config._vitePluginServerEntry.inject) {

@@ -65,4 +67,4 @@ const entries = (0, utils_1.normalizeRollupInput)(config.build.rollupOptions.input);

return;
serverIndexFilePath = config._vitePluginServerEntry.inject ? getServerIndexFilePath(config) : null;
clearAutoImporterFile({ status: 'BUILDING' });
injectEntries = config._vitePluginServerEntry.inject ? getInjectEntries(config) : null;
clearAutoImporter(config);
},

@@ -88,4 +90,4 @@ resolveId(id) {

return;
const isInject = config._vitePluginServerEntry.inject;
if (isInject) {
const { inject } = config._vitePluginServerEntry;
if (inject) {
(0, utils_1.assert)(injectDone);

@@ -95,6 +97,4 @@ }

// Write node_modules/@brillout/vite-plugin-server-entry/dist/autoImporter.js
const isTestCrawler = config._vitePluginServerEntry.testCrawler;
const doNotAutoImport = isInject || (0, utils_1.isYarnPnP)() || isTestCrawler;
if (!doNotAutoImport) {
(0, utils_1.assert)(!isInject && entry);
if (!isAutoImportDisabled(config)) {
(0, utils_1.assert)(!inject && entry);
const entryFileName = entry.fileName;

@@ -104,21 +104,4 @@ writeAutoImporterFile(config, entryFileName);

else {
const status = isTestCrawler ? 'TEST_CRAWLER' : 'DISABLED';
clearAutoImporterFile({ status });
(0, debugLogsBuildTime_1.debugLogsBuildtime)({ disabled: true, paths: null });
}
if (!isInject) {
;
['importBuild.cjs', 'importBuild.mjs', 'importBuild.js'].forEach((fileName) => {
(0, utils_1.assert)(!isInject && entry);
const entryFileName = entry.fileName;
this.emitFile({
fileName,
type: 'asset',
source: [
`globalThis.${serverEntryImportPromise_1.serverEntryImportPromise} = import('./${entryFileName}');`,
`console.warn("[Warning] The server entry has been renamed from dist/server/importBuild.{cjs,mjs,js} to dist/server/entry.{cjs,mjs,js} — update your import('../path/to/dist/server/importBuild.{cjs,mjs,js}') accordingly.");`
].join('\n')
});
});
}
},

@@ -130,4 +113,4 @@ transform(code, id) {

return;
(0, utils_1.assert)(serverIndexFilePath);
if (id !== serverIndexFilePath)
(0, utils_1.assert)(injectEntries);
if (!injectEntries.includes(id))
return;

@@ -171,18 +154,11 @@ {

}
exports.serverEntryPlugin = serverEntryPlugin;
function resolveConfig(configUnresolved, pluginConfigProvidedByLibrary) {
(0, utils_1.assert)((0, utils_1.viteIsSSR)(configUnresolved));
const pluginConfigProvidedByUser = configUnresolved.vitePluginServerEntry;
const pluginConfigResolved = configUnresolved._vitePluginServerEntry ?? {
libraries: [],
apiVersion,
testCrawler: false,
autoImport: true,
inject: false
};
if (pluginConfigProvidedByLibrary.inject) {
pluginConfigResolved.inject = true;
}
if (pluginConfigProvidedByUser?._testCrawler) {
pluginConfigResolved.testCrawler = true;
}
setInjectConfig(pluginConfigResolved, pluginConfigProvidedByLibrary.inject);
// @ts-expect-error workaround for previously broken api version assertion

@@ -203,2 +179,24 @@ pluginConfigResolved.configVersion = 1;

}
function applyPluginConfigProvidedByUser(config) {
const pluginConfigResolved = config._vitePluginServerEntry;
const pluginConfigProvidedByUser = config.vitePluginServerEntry ?? {};
setInjectConfig(pluginConfigResolved, pluginConfigProvidedByUser.inject);
if (pluginConfigProvidedByUser.autoImport !== undefined) {
pluginConfigResolved.autoImport = pluginConfigProvidedByUser.autoImport;
}
}
function setInjectConfig(pluginConfigResolved, inject) {
if (!inject)
return;
if (inject === true) {
if (!pluginConfigResolved.inject) {
pluginConfigResolved.inject = true;
}
return;
}
if (!Array.isArray(pluginConfigResolved.inject)) {
pluginConfigResolved.inject = [];
}
pluginConfigResolved.inject.push(...inject);
}
function isLeaderPluginInstance(config, library) {

@@ -238,2 +236,3 @@ const { libraries } = config._vitePluginServerEntry;

(0, utils_1.assertPosixPath)(root);
(0, utils_1.assert)(!isAutoImportDisabled(config));
(0, utils_1.assert)(!(0, utils_1.isYarnPnP)());

@@ -253,6 +252,26 @@ (0, fs_1.writeFileSync)(autoImporterFilePath, [

}
function clearAutoImporterFile(autoImporter) {
if ((0, utils_1.isYarnPnP)())
function clearAutoImporter(config) {
let status;
if (!isAutoImportDisabled(config)) {
status = 'BUILDING';
}
else {
const { inject, autoImport } = config._vitePluginServerEntry;
if ((0, utils_1.isYarnPnP)()) {
return;
}
else if (!autoImport) {
status = 'DISABLED_BY_USER';
}
else {
(0, utils_1.assert)(inject);
status = 'DISABLED_BY_INJECT';
}
}
(0, utils_1.assert)(status);
const autoImporterContent = (0, fs_1.readFileSync)(autoImporterFilePath);
if (autoImporterContent.includes(status))
return;
(0, fs_1.writeFileSync)(autoImporterFilePath, [`exports.status = '${autoImporter.status}';`, ''].join('\n'));
(0, utils_1.assert)(!(0, utils_1.isYarnPnP)());
(0, fs_1.writeFileSync)(autoImporterFilePath, [`exports.status = '${status}';`, ''].join('\n'));
}

@@ -345,6 +364,5 @@ /** Is `semver1` higher than `semver2`?*/

function findServerEntry(bundle) {
const entry =
// prettier-ignore
(0, utils_1.findRollupBundleEntry)(serverEntryFileNameBase_1.serverEntryFileNameBaseAlternative, bundle) ||
const entry = (0, utils_1.findRollupBundleEntry)(serverEntryFileNameBase_1.serverEntryFileNameBaseAlternative, bundle) ||
(0, utils_1.findRollupBundleEntry)(serverEntryFileNameBase_1.serverEntryFileNameBase, bundle) ||
// Does it make sense? Shouldn't it be removed, or be the list all inject entries?
(0, utils_1.findRollupBundleEntry)(indexEntryName, bundle);

@@ -359,15 +377,23 @@ (0, utils_1.assertUsage)(entry, errMsgEntryRemoved([

}
exports.findServerEntry = findServerEntry;
function getServerIndexFilePath(config) {
function getInjectEntries(config) {
(0, utils_1.assert)(config._vitePluginServerEntry.inject !== false);
const entries = (0, utils_1.normalizeRollupInput)(config.build.rollupOptions.input);
let serverEntryFilePath = entries[indexEntryName];
if (!serverEntryFilePath) {
const injectEntryNames = config._vitePluginServerEntry.inject === true ? [indexEntryName] : config._vitePluginServerEntry.inject;
const injectEntries = injectEntryNames
.map((entryName) => {
let entryFilePath = entries[entryName];
if (!entryFilePath)
return null;
entryFilePath = require.resolve(entryFilePath);
// Needs to be absolute, otherwise it won't match the `id` in `transform(id)`
(0, utils_1.assert)(path_1.default.isAbsolute(entryFilePath));
entryFilePath = (0, utils_1.toPosixPath)(entryFilePath);
return entryFilePath;
})
.filter((e) => e !== null);
if (injectEntries.length === 0) {
const entryNames = Object.keys(entries);
(0, utils_1.assertUsage)(false, errMsgEntryRemoved([indexEntryName], entryNames));
(0, utils_1.assertUsage)(false, errMsgEntryRemoved(injectEntryNames, entryNames));
}
serverEntryFilePath = require.resolve(serverEntryFilePath);
// Needs to be absolute, otherwise it won't match the `id` in `transform(id)`
(0, utils_1.assert)(path_1.default.isAbsolute(serverEntryFilePath));
serverEntryFilePath = (0, utils_1.toPosixPath)(serverEntryFilePath);
return serverEntryFilePath;
return injectEntries;
}

@@ -384,1 +410,5 @@ function errMsgEntryRemoved(entriesMissing, entriesExisting) {

}
function isAutoImportDisabled(config) {
const { inject, autoImport } = config._vitePluginServerEntry;
return (0, utils_1.isYarnPnP)() || !!inject || !autoImport;
}
export { DEBUG };
export { logDebug };
declare const DEBUG = false;
declare const DEBUG: boolean;
declare function logDebug(...msgs: unknown[]): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.logDebug = exports.DEBUG = void 0;
exports.DEBUG = void 0;
exports.logDebug = logDebug;
const utils_1 = require("./utils");

@@ -10,2 +11,1 @@ const DEBUG = false;

}
exports.logDebug = logDebug;
export { assert };
export { assertUsage };
export { logLabel };
declare const logLabel: "[@brillout/vite-plugin-server-entry@0.4.8]";
declare const logLabel: "[@brillout/vite-plugin-server-entry@0.4.9]";
declare function assert(condition: unknown, debugInfo?: unknown): asserts condition;
declare function assertUsage(condition: unknown, errorMessage: string): asserts condition;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.logLabel = exports.assertUsage = exports.assert = void 0;
exports.logLabel = void 0;
exports.assert = assert;
exports.assertUsage = assertUsage;
const createErrorWithCleanStackTrace_1 = require("./createErrorWithCleanStackTrace");

@@ -33,3 +35,2 @@ const projectInfo_1 = require("./projectInfo");

}
exports.assert = assert;
function assertUsage(condition, errorMessage) {

@@ -43,3 +44,2 @@ if (condition) {

}
exports.assertUsage = assertUsage;
/*

@@ -46,0 +46,0 @@ export { assertWarning }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createErrorWithCleanStackTrace = void 0;
exports.createErrorWithCleanStackTrace = createErrorWithCleanStackTrace;
function createErrorWithCleanStackTrace(errorMessage, numberOfStackTraceLinesToRemove) {

@@ -9,3 +9,2 @@ const err = new Error(errorMessage);

}
exports.createErrorWithCleanStackTrace = createErrorWithCleanStackTrace;
function clean(errStack, numberOfStackTraceLinesToRemove) {

@@ -12,0 +11,0 @@ if (!errStack) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toSystemPath = exports.assertPosixPath = exports.toPosixPath = void 0;
exports.toPosixPath = toPosixPath;
exports.assertPosixPath = assertPosixPath;
exports.toSystemPath = toSystemPath;
const assert_1 = require("./assert");

@@ -19,7 +21,5 @@ const sepPosix = '/';

}
exports.toPosixPath = toPosixPath;
function assertPosixPath(path) {
(0, assert_1.assert)(path && !path.includes(sepWin32), `Wrongly formatted path: ${path}`);
}
exports.assertPosixPath = assertPosixPath;
function toSystemPath(path) {

@@ -34,3 +34,2 @@ if (isPosix()) {

}
exports.toSystemPath = toSystemPath;
function isWin32() {

@@ -37,0 +36,0 @@ return process.platform === 'win32';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findRollupBundleEntry = void 0;
exports.findRollupBundleEntry = findRollupBundleEntry;
function findRollupBundleEntry(entryName, bundle) {

@@ -14,2 +14,1 @@ for (const key in bundle) {

}
exports.findRollupBundleEntry = findRollupBundleEntry;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCwd = void 0;
exports.getCwd = getCwd;
const filesystemPathHandling_1 = require("./filesystemPathHandling");

@@ -10,2 +10,1 @@ function getCwd() {

}
exports.getCwd = getCwd;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeRollupInput = exports.injectRollupInputs = void 0;
exports.injectRollupInputs = injectRollupInputs;
exports.normalizeRollupInput = normalizeRollupInput;
const assert_js_1 = require("./assert.js");

@@ -14,3 +15,2 @@ const isObject_js_1 = require("./isObject.js");

}
exports.injectRollupInputs = injectRollupInputs;
function normalizeRollupInput(input) {

@@ -30,2 +30,1 @@ if (!input) {

}
exports.normalizeRollupInput = normalizeRollupInput;

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.isAbsolutePath = void 0;
exports.isAbsolutePath = isAbsolutePath;
const path_1 = __importDefault(require("path"));

@@ -26,2 +26,1 @@ const filesystemPathHandling_1 = require("./filesystemPathHandling");

}
exports.isAbsolutePath = isAbsolutePath;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isObject = void 0;
exports.isObject = isObject;
function isObject(value) {
return typeof value === 'object' && value !== null;
}
exports.isObject = isObject;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isYarnPnP = void 0;
exports.isYarnPnP = isYarnPnP;
function isYarnPnP() {

@@ -13,2 +13,1 @@ try {

}
exports.isYarnPnP = isYarnPnP;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.joinEnglish = void 0;
exports.joinEnglish = joinEnglish;
const assert_js_1 = require("./assert.js");

@@ -14,2 +14,1 @@ // https://stackoverflow.com/questions/53879088/join-an-array-by-commas-and-and/53879103#53879103

}
exports.joinEnglish = joinEnglish;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.objectAssign = void 0;
exports.objectAssign = objectAssign;
// Same as `Object.assign()` but with type inference

@@ -8,2 +8,1 @@ function objectAssign(obj, objAddendum) {

}
exports.objectAssign = objectAssign;

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

export declare const PROJECT_VERSION: "0.4.8";
export declare const PROJECT_VERSION: "0.4.9";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PROJECT_VERSION = void 0;
exports.PROJECT_VERSION = '0.4.8';
exports.PROJECT_VERSION = '0.4.9';
export declare const projectInfo: {
projectName: "@brillout/vite-plugin-server-entry";
npmPackageName: "@brillout/vite-plugin-server-entry";
projectVersion: "0.4.8";
projectVersion: "0.4.9";
githubRepository: "https://github.com/brillout/vite-plugin-server-entry";
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.requireResolve = void 0;
exports.requireResolve = requireResolve;
const import_1 = require("@brillout/import");

@@ -15,3 +15,2 @@ // Workaround for webpack static analysis warnings: (Some users use webpack to bundle their VPS app's server code.)

}
exports.requireResolve = requireResolve;
/* Not needed since using import_() is equivalent

@@ -18,0 +17,0 @@ export { require_ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.viteIsSSR = void 0;
exports.viteIsSSR = viteIsSSR;
function viteIsSSR(config) {
return !!config?.build?.ssr;
}
exports.viteIsSSR = viteIsSSR;
{
"name": "@brillout/vite-plugin-server-entry",
"version": "0.4.8",
"version": "0.4.9",
"dependencies": {

@@ -8,4 +8,14 @@ "@brillout/import": "^0.2.3"

"scripts": {
"========= Dev": "",
"dev": "tsc --watch",
"========= Build": "",
"build": "rm -rf dist/ && tsc",
"========= Formatting": "",
"format": "pnpm run format:biome",
"format:prettier": "git ls-files | egrep '\\.(json|js|jsx|css|ts|tsx|vue|mjs|cjs)$' | grep --invert-match package.json | xargs pnpm exec prettier --write",
"format:biome": "biome format --write .",
"format:check": "biome format . || echo Fix formatting by running: $ pnpm run format",
"========= Reset": "",
"reset": "git clean -Xdf && pnpm install && pnpm run build",
"========= Release": "",
"release": "release-me patch",

@@ -16,5 +26,7 @@ "release:minor": "release-me minor",

"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@brillout/release-me": "^0.4.0",
"@types/node": "^15.12.2",
"typescript": "^4.3.5",
"prettier": "^3.3.3",
"typescript": "^5.5.4",
"vite": "^4.5.1"

@@ -21,0 +33,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