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

@astrojs/solid-js

Package Overview
Dependencies
Maintainers
4
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@astrojs/solid-js - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

6

CHANGELOG.md
# @astrojs/solid-js
## 1.2.2
### Patch Changes
- [#5208](https://github.com/withastro/astro/pull/5208) [`c98c5aa0a`](https://github.com/withastro/astro/commit/c98c5aa0aecb4625aeedc2ffdad69f8b2cd2c153) Thanks [@bluwy](https://github.com/bluwy)! - Improve third-party solid packages config handling
## 1.2.1

@@ -4,0 +10,0 @@

2

dist/dependencies.d.ts

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

export declare function getSolidDeps(root: URL): string[];
export declare function getSolidPkgsConfig(root: URL, isBuild: boolean): Promise<import("vitefu").CrawlFrameworkPkgsResult>;

@@ -1,5 +0,12 @@

import fs from "fs";
import { createRequire } from "module";
import path from "path";
import { fileURLToPath } from "url";
import { crawlFrameworkPkgs } from "vitefu";
async function getSolidPkgsConfig(root, isBuild) {
return await crawlFrameworkPkgs({
root: fileURLToPath(root),
isBuild,
isFrameworkPkgByJson(pkgJson) {
return containsSolidField(pkgJson.exports || {});
}
});
}
function containsSolidField(fields) {

@@ -11,3 +18,3 @@ const keys = Object.keys(fields);

return true;
if (typeof fields[key] === "object" && containsSolidField(fields[key]))
if (typeof fields[key] === "object" && fields[key] != null && containsSolidField(fields[key]))
return true;

@@ -17,42 +24,4 @@ }

}
function getSolidDeps(root) {
const pkgPath = path.join(fileURLToPath(root), "package.json");
if (!fs.existsSync(pkgPath)) {
console.log("No package.json found at project root");
return [];
}
const require2 = createRequire(pkgPath);
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
const deps = [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.devDependencies || {})];
const pkgs = deps.map((dep) => {
try {
return require2(`${dep}/package.json`);
} catch {
try {
let dir = path.dirname(require2.resolve(dep));
while (dir) {
const subPkgPath = path.join(dir, "package.json");
if (fs.existsSync(subPkgPath)) {
const subPkg = JSON.parse(fs.readFileSync(subPkgPath, "utf-8"));
if (subPkg && subPkg.name === dep)
return subPkg;
}
const parent = path.dirname(dir);
if (parent === dir) {
break;
}
dir = parent;
}
} catch {
}
}
});
return deps.reduce((acc, dep, i) => {
if (pkgs[i] && pkgs[i].exports && containsSolidField(pkgs[i].exports))
acc.push(dep);
return acc;
}, []);
}
export {
getSolidDeps
getSolidPkgsConfig
};

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

import { getSolidDeps } from "./dependencies.js";
import { getSolidPkgsConfig } from "./dependencies.js";
function getRenderer() {

@@ -19,4 +19,5 @@ return {

}
function getViteConfiguration(isDev, root) {
async function getViteConfiguration(isDev, root) {
const nestedDeps = ["solid-js", "solid-js/web", "solid-js/store", "solid-js/html", "solid-js/h"];
const solidPkgsConfig = await getSolidPkgsConfig(root, !isDev);
return {

@@ -30,9 +31,9 @@ esbuild: { include: /\.ts$/ },

optimizeDeps: {
include: nestedDeps,
exclude: ["@astrojs/solid-js/server.js"]
include: [...nestedDeps, ...solidPkgsConfig.optimizeDeps.include],
exclude: ["@astrojs/solid-js/server.js", ...solidPkgsConfig.optimizeDeps.exclude]
},
ssr: {
external: ["babel-preset-solid"],
target: "node",
noExternal: ["solid-js", ...getSolidDeps(root)]
external: ["babel-preset-solid", ...solidPkgsConfig.ssr.external],
noExternal: ["solid-js", ...solidPkgsConfig.ssr.noExternal]
}

@@ -45,5 +46,5 @@ };

hooks: {
"astro:config:setup": ({ command, addRenderer, updateConfig, config }) => {
"astro:config:setup": async ({ command, addRenderer, updateConfig, config }) => {
addRenderer(getRenderer());
updateConfig({ vite: getViteConfiguration(command === "dev", config.root) });
updateConfig({ vite: await getViteConfiguration(command === "dev", config.root) });
}

@@ -50,0 +51,0 @@ }

{
"name": "@astrojs/solid-js",
"version": "1.2.1",
"version": "1.2.2",
"description": "Use Solid components within Astro",

@@ -30,6 +30,7 @@ "type": "module",

"dependencies": {
"babel-preset-solid": "^1.4.2"
"babel-preset-solid": "^1.4.2",
"vitefu": "^0.1.0"
},
"devDependencies": {
"astro": "1.5.1",
"astro": "1.6.1",
"astro-scripts": "0.0.8",

@@ -36,0 +37,0 @@ "solid-js": "^1.5.1"

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

// This file is a fork of vite-plugin-solid.
// Original: https://github.com/solidjs/vite-plugin-solid/blob/03130c8a0a2ceaab9a07e16f1e1df832b996e1b8/src/index.ts#L251-L297
// License: MIT (https://github.com/solidjs/vite-plugin-solid/blob/03130c8a0a2ceaab9a07e16f1e1df832b996e1b8/package.json#L38)
import fs from 'fs';
import { createRequire } from 'module';
import path from 'path';
import { fileURLToPath } from 'url';
import { crawlFrameworkPkgs } from 'vitefu';
export async function getSolidPkgsConfig(root: URL, isBuild: boolean) {
return await crawlFrameworkPkgs({
root: fileURLToPath(root),
isBuild,
isFrameworkPkgByJson(pkgJson) {
return containsSolidField(pkgJson.exports || {});
},
});
}
// Reference vite-plugin-solid heuristic
// https://github.com/solidjs/vite-plugin-solid/blob/5558486b0c63788e1275244256918f80294a8338/src/index.ts#L251-L259
// License: MIT (https://github.com/solidjs/vite-plugin-solid/blob/5558486b0c63788e1275244256918f80294a8338/package.json#L38)
function containsSolidField(fields: Record<string, any>) {

@@ -15,42 +22,6 @@ const keys = Object.keys(fields);

if (key === 'solid') return true;
if (typeof fields[key] === 'object' && containsSolidField(fields[key])) return true;
if (typeof fields[key] === 'object' && fields[key] != null && containsSolidField(fields[key]))
return true;
}
return false;
}
export function getSolidDeps(root: URL) {
const pkgPath = path.join(fileURLToPath(root), 'package.json');
if (!fs.existsSync(pkgPath)) {
// eslint-disable-next-line no-console
console.log('No package.json found at project root');
return [];
}
const require = createRequire(pkgPath);
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
const deps = [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.devDependencies || {})];
const pkgs = deps.map((dep) => {
try {
return require(`${dep}/package.json`);
} catch {
try {
let dir = path.dirname(require.resolve(dep));
while (dir) {
const subPkgPath = path.join(dir, 'package.json');
if (fs.existsSync(subPkgPath)) {
const subPkg = JSON.parse(fs.readFileSync(subPkgPath, 'utf-8'));
if (subPkg && subPkg.name === dep) return subPkg;
}
const parent = path.dirname(dir);
if (parent === dir) {
break;
}
dir = parent;
}
} catch {}
}
});
return deps.reduce<string[]>((acc, dep, i) => {
if (pkgs[i] && pkgs[i].exports && containsSolidField(pkgs[i].exports)) acc.push(dep);
return acc;
}, []);
}
import type { AstroIntegration, AstroRenderer } from 'astro';
import { getSolidDeps } from './dependencies.js';
import { getSolidPkgsConfig } from './dependencies.js';

@@ -27,6 +27,7 @@ function getRenderer(): AstroRenderer {

function getViteConfiguration(isDev: boolean, root: URL) {
async function getViteConfiguration(isDev: boolean, root: URL) {
// https://github.com/solidjs/vite-plugin-solid
// We inject the dev mode only if the user explicitely wants it or if we are in dev (serve) mode
const nestedDeps = ['solid-js', 'solid-js/web', 'solid-js/store', 'solid-js/html', 'solid-js/h'];
const solidPkgsConfig = await getSolidPkgsConfig(root, !isDev);
return {

@@ -44,9 +45,9 @@ /**

optimizeDeps: {
include: nestedDeps,
exclude: ['@astrojs/solid-js/server.js'],
include: [...nestedDeps, ...solidPkgsConfig.optimizeDeps.include],
exclude: ['@astrojs/solid-js/server.js', ...solidPkgsConfig.optimizeDeps.exclude],
},
ssr: {
external: ['babel-preset-solid'],
target: 'node',
noExternal: ['solid-js', ...getSolidDeps(root)],
external: ['babel-preset-solid', ...solidPkgsConfig.ssr.external],
noExternal: ['solid-js', ...solidPkgsConfig.ssr.noExternal],
},

@@ -60,5 +61,5 @@ };

hooks: {
'astro:config:setup': ({ command, addRenderer, updateConfig, config }) => {
'astro:config:setup': async ({ command, addRenderer, updateConfig, config }) => {
addRenderer(getRenderer());
updateConfig({ vite: getViteConfiguration(command === 'dev', config.root) });
updateConfig({ vite: await getViteConfiguration(command === 'dev', config.root) });
},

@@ -65,0 +66,0 @@ },

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