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

@stackbit/sdk

Package Overview
Dependencies
Maintainers
13
Versions
424
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stackbit/sdk - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

26

dist/config/config-loader-esbuild.js

@@ -36,5 +36,10 @@ "use strict";

configPath = path.resolve(configPath);
logger === null || logger === void 0 ? void 0 : logger.debug(`[config-loader-esbuilt] building stackbit config from ${configPath}`);
logger = logger === null || logger === void 0 ? void 0 : logger.createLogger({ label: 'config-loader-esbuilt' });
logger === null || logger === void 0 ? void 0 : logger.debug(`building stackbit config from ${configPath}`);
const projectDir = path.dirname(configPath);
const fileName = path.basename(configPath);
// clean previously cached files
if (outDir) {
await fs.emptyDir(outDir);
}
const tempDir = outDir ? path.resolve(projectDir, outDir) : await fs.mkdtemp(path.join(os.tmpdir(), 'stackbit-config-'));

@@ -49,3 +54,3 @@ const outfilePath = path.join(tempDir, 'stackbit.config.cjs');

platform: 'node',
target: 'es2020',
target: 'es2019',
format: 'cjs',

@@ -58,5 +63,13 @@ jsx: 'transform',

external: ['./node_modules/*'],
banner: {
js: `function stackbit_process_cwd_shim() { return "${projectDir}" }`
},
define: {
__dirname: `"${projectDir}"`,
__filename: `"${configPath}"`,
'process.cwd': 'stackbit_process_cwd_shim'
},
watch: watch ? { onRebuild: onRebuildHandler(fileName, projectDir, callback, logger) } : false
});
const configResult = await getConfigFromResult(result, fileName, projectDir);
const configResult = await getConfigFromResult(result, fileName, projectDir, logger);
return {

@@ -93,3 +106,3 @@ ...configResult,

return async (error, result) => {
logger === null || logger === void 0 ? void 0 : logger.debug('[config-loader-esbuilt] stackbit config rebuilt');
logger === null || logger === void 0 ? void 0 : logger.debug(`${fileName} was changed and rebuilt`);
if (error) {

@@ -104,3 +117,3 @@ callback === null || callback === void 0 ? void 0 : callback({

else if (result) {
const configResult = await getConfigFromResult(result, fileName, projectDir);
const configResult = await getConfigFromResult(result, fileName, projectDir, logger);
try {

@@ -115,3 +128,3 @@ callback === null || callback === void 0 ? void 0 : callback(configResult);

}
async function getConfigFromResult(result, fileName, projectDir) {
async function getConfigFromResult(result, fileName, projectDir, logger) {
try {

@@ -133,2 +146,3 @@ // TODO: if the loaded code has error it will provide sourcemaps;

const absOutputFilePath = path.join(projectDir, outfilePath);
logger === null || logger === void 0 ? void 0 : logger.debug(`loading compiled ${fileName} from ${outfilePath}`);
const exports = importFresh(absOutputFilePath);

@@ -135,0 +149,0 @@ if ('__esModule' in exports && exports.__esModule) {

@@ -8,3 +8,3 @@ /// <reference types="node" />

export declare type StricterUnion<Union, Union2 = Union> = Union2 extends any ? StricterUnionMember<Union2, Union> : never;
export declare type Logger = Pick<Console, 'log' | 'debug' | 'info' | 'warn' | 'error'>;
export declare type Logger = Pick<Console, 'debug' | 'info' | 'warn' | 'error'>;
export * from './model-utils';

@@ -11,0 +11,0 @@ export * from './model-matcher';

{
"name": "@stackbit/sdk",
"version": "0.3.1",
"version": "0.3.2",
"description": "Stackbit SDK",

@@ -40,3 +40,3 @@ "main": "dist/index.js",

"@octokit/rest": "^18.3.5",
"@stackbit/utils": "^0.2.8",
"@stackbit/utils": "^0.2.9",
"acorn": "^8.2.4",

@@ -70,3 +70,3 @@ "chokidar": "^3.5.3",

},
"gitHead": "93193990ec5d1465848b8256e980fd31120aa12f"
"gitHead": "d94b36afc0e7e1cf83539029aba8aa965933dae5"
}

@@ -26,5 +26,12 @@ import * as esbuild from 'esbuild';

configPath = path.resolve(configPath);
logger?.debug(`[config-loader-esbuilt] building stackbit config from ${configPath}`);
logger = logger?.createLogger({ label: 'config-loader-esbuilt' });
logger?.debug(`building stackbit config from ${configPath}`);
const projectDir = path.dirname(configPath);
const fileName = path.basename(configPath);
// clean previously cached files
if (outDir) {
await fs.emptyDir(outDir);
}
const tempDir = outDir ? path.resolve(projectDir, outDir) : await fs.mkdtemp(path.join(os.tmpdir(), 'stackbit-config-'));

@@ -39,3 +46,3 @@ const outfilePath = path.join(tempDir, 'stackbit.config.cjs');

platform: 'node',
target: 'es2020',
target: 'es2019', // TODO: update container to node 16 and set this to es2020
format: 'cjs',

@@ -48,5 +55,13 @@ jsx: 'transform', // needed in case models are co-located with React components

external: ['./node_modules/*'],
banner: {
js: `function stackbit_process_cwd_shim() { return "${projectDir}" }`
},
define: {
__dirname: `"${projectDir}"`,
__filename: `"${configPath}"`,
'process.cwd': 'stackbit_process_cwd_shim'
},
watch: watch ? { onRebuild: onRebuildHandler(fileName, projectDir, callback, logger) } : false
});
const configResult = await getConfigFromResult(result, fileName, projectDir);
const configResult = await getConfigFromResult(result, fileName, projectDir, logger);
return {

@@ -81,3 +96,3 @@ ...configResult,

return async (error: esbuild.BuildFailure | null, result: esbuild.BuildResult | null) => {
logger?.debug('[config-loader-esbuilt] stackbit config rebuilt');
logger?.debug(`${fileName} was changed and rebuilt`);
if (error) {

@@ -91,3 +106,3 @@ callback?.({

} else if (result) {
const configResult = await getConfigFromResult(result, fileName, projectDir);
const configResult = await getConfigFromResult(result, fileName, projectDir, logger);
try {

@@ -102,3 +117,3 @@ callback?.(configResult);

async function getConfigFromResult(result: esbuild.BuildResult, fileName: string, projectDir: string): Promise<LoadRawConfigResult> {
async function getConfigFromResult(result: esbuild.BuildResult, fileName: string, projectDir: string, logger?: any): Promise<LoadRawConfigResult> {
try {

@@ -124,2 +139,4 @@ // TODO: if the loaded code has error it will provide sourcemaps;

logger?.debug(`loading compiled ${fileName} from ${outfilePath}`);
const exports = importFresh(absOutputFilePath);

@@ -126,0 +143,0 @@

@@ -12,3 +12,3 @@ type UnionKeys<U> = U extends any ? keyof U : never;

export type Logger = Pick<Console, 'log' | 'debug' | 'info' | 'warn' | 'error'>;
export type Logger = Pick<Console, 'debug' | 'info' | 'warn' | 'error'>;

@@ -15,0 +15,0 @@ export * from './model-utils';

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