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

@sveltejs/adapter-netlify

Package Overview
Dependencies
Maintainers
4
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sveltejs/adapter-netlify - npm Package Compare versions

Comparing version 1.0.0-next.5 to 1.0.0-next.6

files/_redirects

6

CHANGELOG.md
# @sveltejs/adapter-netlify
## 1.0.0-next.6
### Patch Changes
- 7a4b351: Bundle serverless functions with esbuild
## 1.0.0-next.5

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

91

index.js

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

const { existsSync, readFileSync, copyFileSync, writeFileSync, renameSync } = require('fs');
const { resolve } = require('path');
const { existsSync, readFileSync, writeFileSync } = require('fs');
const { join } = require('path');
const esbuild = require('esbuild');
const toml = require('toml');

@@ -11,48 +12,21 @@

async adapt(utils) {
let netlify_config;
const { publish, functions } = validate_config().build;
if (existsSync('netlify.toml')) {
try {
netlify_config = toml.parse(readFileSync('netlify.toml', 'utf-8'));
} catch (err) {
err.message = `Error parsing netlify.toml: ${err.message}`;
throw err;
}
} else {
// TODO offer to create one?
throw new Error(
'Missing a netlify.toml file. Consult https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#configuration'
);
}
utils.rimraf(publish);
utils.rimraf(functions);
if (
!netlify_config.build ||
!netlify_config.build.publish ||
!netlify_config.build.functions
) {
throw new Error(
'You must specify build.publish and build.functions in netlify.toml. Consult https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#configuration'
);
}
const files = join(__dirname, 'files');
const publish = resolve(netlify_config.build.publish);
const functions = resolve(netlify_config.build.functions);
utils.log.minor('Generating serverless function...');
utils.copy(join(files, 'entry.js'), '.svelte/netlify/entry.js');
utils.copy_static_files(publish);
utils.copy_client_files(publish);
utils.copy_server_files(`${functions}/render`);
await esbuild.build({
entryPoints: ['.svelte/netlify/entry.js'],
outfile: join(functions, 'index.js'),
bundle: true,
platform: 'node'
});
// rename app to .mjs
renameSync(`${functions}/render/app.js`, `${functions}/render/app.mjs`);
writeFileSync(join(functions, 'package.json'), JSON.stringify({ type: 'commonjs' }));
// copy the renderer
copyFileSync(resolve(__dirname, 'files/render.js'), `${functions}/render/handler.mjs`);
// copy the entry point
copyFileSync(resolve(__dirname, 'files/index.cjs'), `${functions}/render/index.js`);
// create _redirects
writeFileSync(`${publish}/_redirects`, '/* /.netlify/functions/render 200');
// prerender
utils.log.info('Prerendering static pages...');

@@ -62,2 +36,9 @@ await utils.prerender({

});
utils.log.minor('Copying assets...');
utils.copy_static_files(publish);
utils.copy_client_files(publish);
utils.log.minor('Writing redirects...');
utils.copy(`${files}/_redirects`, `${publish}/_redirects`);
}

@@ -68,1 +49,27 @@ };

};
function validate_config() {
if (existsSync('netlify.toml')) {
let netlify_config;
try {
netlify_config = toml.parse(readFileSync('netlify.toml', 'utf-8'));
} catch (err) {
err.message = `Error parsing netlify.toml: ${err.message}`;
throw err;
}
if (!netlify_config.build || !netlify_config.build.publish || !netlify_config.build.functions) {
throw new Error(
'You must specify build.publish and build.functions in netlify.toml. Consult https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#configuration'
);
}
return netlify_config;
}
// TODO offer to create one?
throw new Error(
'Missing a netlify.toml file. Consult https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#configuration'
);
}
{
"name": "@sveltejs/adapter-netlify",
"version": "1.0.0-next.5",
"version": "1.0.0-next.6",
"main": "index.js",

@@ -12,3 +12,3 @@ "files": [

"devDependencies": {
"@sveltejs/kit": "1.0.0-next.78",
"@sveltejs/kit": "1.0.0-next.80",
"typescript": "^4.2.3"

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