Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
esbuild-svelte
Advanced tools
Plugin to compile svelte components for bundling with esbuild.
Install this plugin, esbuild and Svelte.
A simple build script looks like
import esbuild from "esbuild";
import sveltePlugin from "esbuild-svelte";
esbuild
.build({
entryPoints: ["app.js"],
mainFields: ["svelte", "browser", "module", "main"],
conditions: ["svelte", "browser"],
bundle: true,
outfile: "out.js",
plugins: [sveltePlugin()],
logLevel: "info",
})
.catch(() => process.exit(1));
The example-js
folder of this repository is a great starting off point for a "complete" project. You can quickly get started using degit:
# Clone the JavaScript example to get started
npx degit EMH333/esbuild-svelte/example-js my-svelte-app
# Clone the TypeScript example to get started
npx degit EMH333/esbuild-svelte/example-ts my-svelte-app
By default, esbuild-svelte
emits external css files from Svelte for esbuild
to process. If this isn't desired, use a configuration that turns off external css output and instead includes it in the javascript output. For example: sveltePlugin({compilerOptions: {css: "injected"}})
In order to support Typescript and other languages that require preprocessing before being fed into the Svelte compiler, simply add the preprocessor to the preprocess
option (which accepts both a single preprocessor or an array of them). The example script below is a great place to start, you can also look at the example-ts
folder for a more complete project.
import esbuild from "esbuild";
import esbuildSvelte from "esbuild-svelte";
import sveltePreprocess from "svelte-preprocess";
esbuild
.build({
entryPoints: ["index.js"],
mainFields: ["svelte", "browser", "module", "main"],
conditions: ["svelte", "browser"],
bundle: true,
outdir: "./dist",
plugins: [
esbuildSvelte({
preprocess: sveltePreprocess(),
}),
],
})
.catch(() => process.exit(1));
Typescript in .svelte.ts
files is supported natively.
svelte
exports conditionIf you are importing a svelte component library, you need to add "svelte"
to conditions
in esbuild build options. This lets esbuild use the svelte
property in svelte component's exports
conditions in package.json
.
For incremental or watch build modes, esbuild-svelte will automatically cache files if they haven't changed. This allows esbuild to skip the Svelte compiler for those files altogether, saving time. Setting cache: false
will disable this file level cache if an issue arises (please report).
You can see the full API for this plugin here, which includes support for Svelte's compiler options, preprocessing API, and more.
Clone, npm install
, npm link
and it's good to go! Releases are automated (with the right permissions), just by running npm version patch|minor|major
.
0.9.0 (Breaking)
This will be the last pre-v1 minor release if all goes according to plan.
*.svelte.js
and *.svelte.ts
Svelte modules (Thank you @ElijahJohnson5 for the contribution!)css
compile option (use external
or injected
instead)4.2.1
0.17.0
overzealous
cache option (was unusable)fromEntryFile
option (was unusable)FAQs
esbuild plugin to resolve .svelte files
The npm package esbuild-svelte receives a total of 30,218 weekly downloads. As such, esbuild-svelte popularity was classified as popular.
We found that esbuild-svelte demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.