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

vite-plugin-wasm-pack

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-wasm-pack - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

24

dist/index.js

@@ -11,2 +11,4 @@ "use strict";

function vitePluginWasmPack(crates) {
const prefix = '@vite-plugin-wasm-pack@';
const pkg = 'pkg';
const cratePaths = narrowing_1.isString(crates) ? [crates] : crates;

@@ -19,3 +21,3 @@ function wasmFilename(cratePath) {

const wasmFile = wasmFilename(cratePath);
wasmMap.set(wasmFile, path_1.default.join(cratePath, 'pkg', wasmFile));
wasmMap.set(wasmFile, path_1.default.join(cratePath, pkg, wasmFile));
});

@@ -25,5 +27,22 @@ return {

enforce: 'pre',
resolveId(id) {
for (let i = 0; i < cratePaths.length; i++) {
if (path_1.default.basename(cratePaths[i]) === id)
return prefix + id;
}
return null;
},
async load(id) {
if (id.indexOf(prefix) === 0) {
id = id.replace(prefix, '');
const modulejs = path_1.default.join('./node_modules', id, id.replace('-', '_') + '.js');
const code = await fs_extra_1.default.promises.readFile(modulejs, {
encoding: 'utf-8'
});
return code;
}
},
async buildStart(inputOptions) {
for await (const cratePath of cratePaths) {
const pkgPath = path_1.default.join(cratePath, 'pkg');
const pkgPath = path_1.default.join(cratePath, pkg);
const crateName = path_1.default.basename(cratePath);

@@ -57,2 +76,3 @@ if (!fs_extra_1.default.existsSync(pkgPath)) {

const basename = path_1.default.basename(req.url);
res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
if (basename.endsWith('.wasm') && wasmMap.get(basename) != null) {

@@ -59,0 +79,0 @@ res.writeHead(200, { 'Content-Type': 'application/wasm' });

2

package.json
{
"name": "vite-plugin-wasm-pack",
"version": "0.1.3",
"version": "0.1.4",
"description": "wasm-pack for Vite",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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