snowpack
Advanced tools
Comparing version 3.8.0-pre.1 to 3.8.0-pre.2
@@ -9,2 +9,8 @@ "use strict"; | ||
const util_1 = require("../util"); | ||
function moduleInit(fn) { | ||
let promise = null; | ||
return function () { | ||
return promise || (promise = fn()); | ||
}; | ||
} | ||
// This function makes it possible to load modules from the snowpack server, for the sake of SSR. | ||
@@ -22,3 +28,3 @@ function createLoader({ config, load }) { | ||
} | ||
return async function () { | ||
return moduleInit(async function () { | ||
const mod = await util_1.REQUIRE_OR_IMPORT(imported, { | ||
@@ -31,3 +37,3 @@ from: config.root || config.workspaceRoot || process.cwd(), | ||
}; | ||
}; | ||
}); | ||
} | ||
@@ -58,3 +64,3 @@ function invalidateModule(path) { | ||
const loaded = await load(url); | ||
return function () { | ||
return moduleInit(function () { | ||
try { | ||
@@ -67,3 +73,3 @@ return initializeModule(url, loaded, urlStack.concat(url)); | ||
} | ||
}; | ||
}); | ||
})(); | ||
@@ -70,0 +76,0 @@ cache.set(url, promise); |
@@ -6,2 +6,8 @@ import { existsSync, readFileSync } from 'fs'; | ||
import { REQUIRE_OR_IMPORT } from '../util'; | ||
function moduleInit(fn) { | ||
let promise = null; | ||
return function () { | ||
return promise || (promise = fn()); | ||
}; | ||
} | ||
// This function makes it possible to load modules from the snowpack server, for the sake of SSR. | ||
@@ -19,3 +25,3 @@ export function createLoader({ config, load }) { | ||
} | ||
return async function () { | ||
return moduleInit(async function () { | ||
const mod = await REQUIRE_OR_IMPORT(imported, { | ||
@@ -28,3 +34,3 @@ from: config.root || config.workspaceRoot || process.cwd(), | ||
}; | ||
}; | ||
}); | ||
} | ||
@@ -55,3 +61,3 @@ function invalidateModule(path) { | ||
const loaded = await load(url); | ||
return function () { | ||
return moduleInit(function () { | ||
try { | ||
@@ -64,3 +70,3 @@ return initializeModule(url, loaded, urlStack.concat(url)); | ||
} | ||
}; | ||
}); | ||
})(); | ||
@@ -67,0 +73,0 @@ cache.set(url, promise); |
{ | ||
"name": "snowpack", | ||
"version": "3.8.0-pre.1", | ||
"version": "3.8.0-pre.2", | ||
"description": "The ESM-powered frontend build tool. Fast, lightweight, unbundled.", | ||
@@ -25,3 +25,3 @@ "author": "Fred K. Schott <fkschott@gmail.com>", | ||
"build": "tsc --noUnusedLocals false --noUnusedParameters false && tsc -p tsconfig.cjs.json", | ||
"build:watch": "tsc --watch --noUnusedLocals false --noUnusedParameters false", | ||
"build:watch": "tsc --watch -p tsconfig.cjs.json", | ||
"lint": "tsc --noEmit" | ||
@@ -28,0 +28,0 @@ }, |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
1332426
244
25288
74
17