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

@preact/preset-vite

Package Overview
Dependencies
Maintainers
0
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@preact/preset-vite - npm Package Compare versions

Comparing version 2.8.2 to 2.8.3

8

dist/cjs/devtools.js

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

const utils_js_1 = require("./utils.js");
function preactDevtoolsPlugin({ injectInProd = false, shouldTransform, }) {
function preactDevtoolsPlugin({ devtoolsInProd, devToolsEnabled, shouldTransform, }) {
const log = (0, debug_1.default)("vite:preact-devtools");

@@ -54,2 +54,4 @@ let entry = "";

config = resolvedConfig;
devToolsEnabled =
devToolsEnabled !== null && devToolsEnabled !== void 0 ? devToolsEnabled : (!config.isProduction || devtoolsInProd);
},

@@ -70,4 +72,4 @@ resolveId(url, importer = "") {

const { id } = (0, utils_js_1.parseId)(url);
if (entry === id && (!config.isProduction || injectInProd)) {
const source = injectInProd ? "preact/devtools" : "preact/debug";
if (entry === id && (!config.isProduction || devToolsEnabled)) {
const source = config.isProduction ? "preact/devtools" : "preact/debug";
code = `import "${source}";\n${code}`;

@@ -74,0 +76,0 @@ log(`[inject] ${kl.cyan(source)} -> ${kl.dim(id)}`);

@@ -31,4 +31,5 @@ "use strict";

(_a = babelOptions.parserOpts).plugins || (_a.plugins = []);
let useBabel;
const shouldTransform = (0, utils_js_1.createFilter)(include || [/\.[tj]sx?$/], exclude || [/node_modules/]);
devToolsEnabled = devToolsEnabled !== null && devToolsEnabled !== void 0 ? devToolsEnabled : true;
devtoolsInProd = devtoolsInProd !== null && devtoolsInProd !== void 0 ? devtoolsInProd : false;
prefreshEnabled = prefreshEnabled !== null && prefreshEnabled !== void 0 ? prefreshEnabled : true;

@@ -53,2 +54,7 @@ reactAliasesEnabled = reactAliasesEnabled !== null && reactAliasesEnabled !== void 0 ? reactAliasesEnabled : true;

},
// While this config is unconditional, it'll only be used if Babel is not
esbuild: {
jsx: "automatic",
jsxImportSource: jsxImportSource !== null && jsxImportSource !== void 0 ? jsxImportSource : "preact",
},
optimizeDeps: {

@@ -61,2 +67,6 @@ include: ["preact/jsx-runtime", "preact/jsx-dev-runtime"],

config = resolvedConfig;
devToolsEnabled =
devToolsEnabled !== null && devToolsEnabled !== void 0 ? devToolsEnabled : (!config.isProduction || devtoolsInProd);
useBabel =
!config.isProduction || devToolsEnabled || typeof babel !== "undefined";
},

@@ -66,3 +76,3 @@ async transform(code, url) {

const { id } = (0, utils_js_1.parseId)(url);
if (!shouldTransform(id))
if (!useBabel || !shouldTransform(id))
return;

@@ -103,3 +113,3 @@ const parserPlugins = [

],
...(devToolsEnabled && !config.isProduction ? ["babel-plugin-transform-hook-names"] : []),
...(devToolsEnabled ? ["babel-plugin-transform-hook-names"] : []),
],

@@ -138,10 +148,7 @@ sourceMaps: true,

jsxPlugin,
...(devToolsEnabled
? [
(0, devtools_js_1.preactDevtoolsPlugin)({
injectInProd: devtoolsInProd,
shouldTransform,
}),
]
: []),
(0, devtools_js_1.preactDevtoolsPlugin)({
devtoolsInProd,
devToolsEnabled,
shouldTransform,
}),
...(prefreshEnabled

@@ -148,0 +155,0 @@ ? [(0, vite_1.default)({ include, exclude, parserPlugins: baseParserOptions })]

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

const source_map_1 = require("source-map");
const stack_trace_1 = require("stack-trace");
const code_frame_1 = require("@babel/code-frame");

@@ -155,2 +154,7 @@ function enc(str) {

globalThis.self = globalThis;
// As of Vite 5.3.0-beta.0, Vite injects an undefined `__VITE_PRELOAD__` var
// Swapping in an empty array is fine as we have no need to preload whilst prerendering
// https://github.com/vitejs/vite/pull/16562
// @ts-ignore
globalThis.__VITE_PRELOAD__ = [];
// Local, fs-based fetch implementation for prerendering

@@ -190,7 +194,12 @@ const nodeFetch = globalThis.fetch;

// Clean up source maps if the user didn't enable them themselves
if (/\.map$/.test(output) && !userEnabledSourceMaps) {
delete bundle[output];
continue;
if (!userEnabledSourceMaps) {
if (output.endsWith(".map")) {
delete bundle[output];
continue;
}
if (output.endsWith(".js") && bundle[output].type == "chunk") {
bundle[output].code = bundle[output].code.replace(/\n\/\/#\ssourceMappingURL=.*/, "");
}
}
if (!/\.js$/.test(output) || bundle[output].type !== "chunk")
if (!output.endsWith(".js") || bundle[output].type !== "chunk")
continue;

@@ -212,3 +221,3 @@ await node_fs_1.promises.writeFile(node_path_1.default.join(tmpDir, node_path_1.default.basename(output)), bundle[output].code);

catch (e) {
const stack = (0, stack_trace_1.parse)(e).find(s => s.getFileName().includes(tmpDir));
const stack = await Promise.resolve().then(() => __importStar(require("stack-trace"))).then(({ parse }) => parse(e).find(s => s.getFileName().includes(tmpDir)));
const isReferenceError = e instanceof ReferenceError;

@@ -215,0 +224,0 @@ let message = `\n

import { Plugin } from "vite";
import type { RollupFilter } from "./utils.js";
export interface PreactDevtoolsPluginOptions {
injectInProd?: boolean;
devtoolsInProd?: boolean;
devToolsEnabled?: boolean;
shouldTransform: RollupFilter;
}
export declare function preactDevtoolsPlugin({ injectInProd, shouldTransform, }: PreactDevtoolsPluginOptions): Plugin;
export declare function preactDevtoolsPlugin({ devtoolsInProd, devToolsEnabled, shouldTransform, }: PreactDevtoolsPluginOptions): Plugin;
{
"name": "@preact/preset-vite",
"version": "2.8.2",
"version": "2.8.3",
"description": "Preact preset for the vite bundler",

@@ -36,2 +36,3 @@ "main": "./dist/cjs/index.js",

"dependencies": {
"@babel/code-frame": "^7.22.13",
"@babel/plugin-transform-react-jsx": "^7.22.15",

@@ -38,0 +39,0 @@ "@babel/plugin-transform-react-jsx-development": "^7.22.5",

@@ -102,3 +102,3 @@ # @preact/preset-vite

export async function prerender(data) {
const html = ssr(<App />);
const { html, links: discoveredLinks } = ssr(<App />);

@@ -109,3 +109,3 @@ return {

// prerendered (if they haven't already been)
links: new Set(['/foo', '/bar']),
links: new Set([...discoveredLinks, '/foo', '/bar']),
// Optionally configure and add elements to the `<head>` of

@@ -112,0 +112,0 @@ // the prerendered HTML document

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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