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

@sveltejs/adapter-cloudflare

Package Overview
Dependencies
Maintainers
4
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sveltejs/adapter-cloudflare - npm Package Compare versions

Comparing version 4.0.2 to 4.1.0

86

index.js

@@ -6,2 +6,17 @@ import { writeFileSync } from 'node:fs';

// list from https://developers.cloudflare.com/workers/runtime-apis/nodejs/
const compatible_node_modules = [
'assert',
'async_hooks',
'buffer',
'crypto',
'diagnostics_channel',
'events',
'path',
'process',
'stream',
'string_decoder',
'util'
];
/** @type {import('./index.js').default} */

@@ -57,17 +72,58 @@ export default function (options = {}) {

await esbuild.build({
platform: 'browser',
conditions: ['worker', 'browser'],
sourcemap: 'linked',
target: 'es2022',
entryPoints: [`${tmp}/_worker.js`],
outfile: `${dest}/_worker.js`,
allowOverwrite: true,
format: 'esm',
bundle: true,
loader: {
'.wasm': 'copy'
},
external: ['cloudflare:*']
});
const external = ['cloudflare:*', ...compatible_node_modules.map((id) => `node:${id}`)];
try {
const result = await esbuild.build({
platform: 'browser',
conditions: ['worker', 'browser'],
sourcemap: 'linked',
target: 'es2022',
entryPoints: [`${tmp}/_worker.js`],
outfile: `${dest}/_worker.js`,
allowOverwrite: true,
format: 'esm',
bundle: true,
loader: {
'.wasm': 'copy'
},
external,
alias: Object.fromEntries(compatible_node_modules.map((id) => [id, `node:${id}`])),
logLevel: 'silent'
});
if (result.warnings.length > 0) {
const formatted = await esbuild.formatMessages(result.warnings, {
kind: 'warning',
color: true
});
console.error(formatted.join('\n'));
}
} catch (error) {
for (const e of error.errors) {
for (const node of e.notes) {
const match =
/The package "(.+)" wasn't found on the file system but is built into node/.exec(
node.text
);
if (match) {
node.text = `Cannot use "${match[1]}" when deploying to Cloudflare.`;
}
}
}
const formatted = await esbuild.formatMessages(error.errors, {
kind: 'error',
color: true
});
console.error(formatted.join('\n'));
throw new Error(
`Bundling with esbuild failed with ${error.errors.length} ${
error.errors.length === 1 ? 'error' : 'errors'
}`
);
}
}

@@ -74,0 +130,0 @@ };

4

package.json
{
"name": "@sveltejs/adapter-cloudflare",
"version": "4.0.2",
"version": "4.1.0",
"description": "Adapter for building SvelteKit applications on Cloudflare Pages with Workers integration",

@@ -36,3 +36,3 @@ "repository": {

"typescript": "^5.3.3",
"@sveltejs/kit": "^2.3.5"
"@sveltejs/kit": "^2.4.0"
},

@@ -39,0 +39,0 @@ "peerDependencies": {

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