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

@sveltejs/adapter-vercel

Package Overview
Dependencies
Maintainers
3
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sveltejs/adapter-vercel - npm Package Compare versions

Comparing version 0.0.3 to 1.0.0-next.0

src/index.js

118

index.js

@@ -1,55 +0,69 @@

const { writeFileSync, readFileSync } = require('fs');
const { resolve, join } = require('path');
const { prerender } = require('@sveltejs/app-utils/renderer');
const { copy } = require('@sveltejs/app-utils/files');
'use strict';
function write_manifest(manifest) {
return `module.exports = {
layout: ${JSON.stringify(manifest.layout)},
error: ${JSON.stringify(manifest.error)},
components: ${JSON.stringify(manifest.components)},
pages: [
${manifest.pages
.map(
page =>
`{ pattern: ${page.pattern}, parts: ${JSON.stringify(page.parts)} }`
)
.join(',\n\t\t\t')}
],
endpoints: [
${manifest.endpoints
.map(
route =>
`{ name: '${route.name}', pattern: ${route.pattern}, file: '${
route.file
}', params: ${JSON.stringify(route.params)} }`
)
.join(',\n\t\t\t')}
]
};`.replace(/^\t/gm, '');
Object.defineProperty(exports, '__esModule', { value: true });
var fs = require('fs');
var path = require('path');
var renderer = require('@sveltejs/app-utils/renderer');
function mkdirp(dir) {
try {
fs.mkdirSync(dir, { recursive: true });
} catch (e) {
if (e.code === 'EEXIST') return;
throw e;
}
}
module.exports = async function builder({ dir, manifest, log }) {
const lambda_directory = resolve('api');
const static_directory = resolve('public');
const server_directory = resolve(join('api', 'server'));
function copy(
from,
to,
filter = () => true
) {
if (!filter(path.basename(from))) return [];
log.minor('Writing client application...');
const files = [];
const stats = fs.statSync(from);
if (stats.isDirectory()) {
fs.readdirSync(from).forEach((file) => {
files.push(...copy(path.join(from, file), path.join(to, file)));
});
} else {
mkdirp(path.dirname(to));
fs.copyFileSync(from, to);
files.push(to);
}
return files;
}
async function builder({
dir,
manifest,
log
}) {
const lambda_directory = path.resolve('api');
const static_directory = path.resolve('public');
const server_directory = path.resolve(path.join('api', 'server'));
log.info('Writing client application...');
copy('static', static_directory);
copy(resolve(dir, 'client'), join(static_directory, '_app'));
copy(path.resolve(dir, 'client'), path.join(static_directory, '_app'));
log.minor('Building lambda...');
copy(resolve(__dirname, 'src'), lambda_directory);
copy(join(resolve(dir), 'client.json'), join(server_directory, 'client.json'));
const written_manifest = write_manifest(manifest);
const htmlPath = resolve('src', 'app.html');
const appHtml = readFileSync(htmlPath, 'utf-8');
writeFileSync(join(server_directory, 'manifest.js'), written_manifest);
writeFileSync(
join(server_directory, 'template.js'),
log.info('Building lambda...');
copy(path.resolve(__dirname, 'src'), lambda_directory);
copy(path.join(path.resolve(dir), 'client.json'), path.join(server_directory, 'client.json'));
const written_manifest = renderer.generate_manifest_module(manifest);
const htmlPath = path.resolve('src', 'app.html');
const appHtml = fs.readFileSync(htmlPath, 'utf-8');
fs.writeFileSync(path.join(server_directory, 'manifest.js'), written_manifest);
fs.writeFileSync(
path.join(server_directory, 'template.js'),
`module.exports = ${JSON.stringify(appHtml)};`
);
log.minor('Prerendering static pages...');
await prerender({
log.info('Prerendering static pages...');
await renderer.prerender({
force: true,
dir,

@@ -61,9 +75,9 @@ out: static_directory,

log.minor('Writing server application...');
copy(resolve(dir, 'server'), server_directory);
log.info('Writing server application...');
copy(path.resolve(dir, 'server'), server_directory);
// TODO: Merge this, rather than write it
log.minor('Rewriting vercel configuration...');
writeFileSync(
`vercel.json`,
log.info('Rewriting vercel configuration...');
fs.writeFileSync(
'vercel.json',
JSON.stringify({

@@ -84,2 +98,4 @@ public: true,

);
};
}
exports.builder = builder;
{
"name": "@sveltejs/adapter-vercel",
"version": "0.0.3",
"devDependencies": {
"@sveltejs/app-utils": "*"
"version": "1.0.0-next.0",
"scripts": {
"build": "rollup -c",
"lint": "eslint --ignore-pattern node_modules/ \"**/*.{ts,js,svelte}\" && npm run check-format",
"format": "prettier --write . --config ../../.prettierrc --ignore-path .gitignore",
"check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
"prepublishOnly": "npm run build"
},

@@ -12,5 +16,6 @@ "main": "index.js",

],
"dependencies": {
"tiny-glob": "^0.2.6"
"devDependencies": {
"@sveltejs/app-utils": "1.0.0-next.0",
"@types/aws-lambda": "^8.10.64"
}
}

@@ -20,2 +20,2 @@ # adapter-vercel

vercel
```
```
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