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

svelte-preprocess-import-assets

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-preprocess-import-assets - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

LICENSE

3

dist/index.d.ts

@@ -23,3 +23,2 @@ import { PreprocessorGroup } from 'svelte/types/compiler/preprocess';

export default importAssets;
export { AssetSource, FilterMetadata, ImportAssetsOptions };
export { AssetSource, FilterMetadata, ImportAssetsOptions, importAssets as default };
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, {get: all[name], enumerable: true});
__defProp(target, name, { get: all[name], enumerable: true });
};
var __reExport = (target, module2, desc) => {
var __reExport = (target, module2, copyDefault, desc) => {
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
for (let key of __getOwnPropNames(module2))
if (!__hasOwnProp.call(target, key) && key !== "default")
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
}
return target;
};
var __toModule = (module2) => {
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
var __toESM = (module2, isNodeMode) => {
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
};
var __toCommonJS = /* @__PURE__ */ ((cache) => {
return (module2, temp) => {
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
};
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
// src/index.ts
__markAsModule(exports);
__export(exports, {
var src_exports = {};
__export(src_exports, {
default: () => importAssets
});
var import_compiler = __toModule(require("svelte/compiler"));
var import_magic_string = __toModule(require("magic-string"));
var import_compiler = require("svelte/compiler");
var import_magic_string = __toESM(require("magic-string"));
function importAssets(options = {}) {

@@ -42,8 +47,10 @@ let {

return {
markup({content, filename}) {
markup({ content, filename }) {
const s = new import_magic_string.default(content);
const ast = (0, import_compiler.parse)(content, {filename});
const imports = new Map();
const ast = (0, import_compiler.parse)(content, { filename });
const imports = /* @__PURE__ */ new Map();
function addImport(attributeValue) {
const url = attributeValue.raw.trim();
if (url.startsWith("#"))
return;
if (!http && /^https?:\/\//.test(url))

@@ -140,3 +147,3 @@ return;

} else {
s.append(`<script>${importText}</script>`);
s.append(`<script>${importText}<\/script>`);
}

@@ -243,3 +250,3 @@ }

srcsetAttributes: ["imagesrcset"],
filter({attributes}) {
filter({ attributes }) {
if (attributes.rel && ALLOWED_REL.includes(attributes.rel.trim().toLowerCase())) {

@@ -257,3 +264,3 @@ return true;

srcAttributes: ["content"],
filter({attributes}) {
filter({ attributes }) {
if (attributes.name && ALLOWED_META_NAME.includes(attributes.name.trim().toLowerCase())) {

@@ -272,3 +279,4 @@ return true;

];
module.exports = __toCommonJS(src_exports);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {});
{
"name": "svelte-preprocess-import-assets",
"description": "Import assets in markup",
"version": "0.1.3",
"version": "0.1.4",
"license": "MIT",

@@ -36,4 +36,4 @@ "author": "Bjorn Lu",

"build": "tsc && tsup src/index.ts --dts --no-splitting --format esm,cjs",
"test": "esno test/index.ts",
"test:update": "esno test/index.ts -u",
"test": "tsm test/index.ts",
"test:update": "tsm test/index.ts -u",
"format": "prettier -w {src,test}/**/*.{ts,svelte}",

@@ -49,11 +49,13 @@ "prepublishOnly": "rm -rf dist && pnpm build"

"devDependencies": {
"@types/node": "^14.14.41",
"esno": "^0.5.0",
"prettier": "^2.2.1",
"prettier-plugin-svelte": "^2.2.0",
"svelte": "^3.37.0",
"tsup": "^4.9.2",
"typescript": "^4.2.4",
"uvu": "^0.5.1"
"@types/node": "^17.0.0",
"prettier": "^2.5.1",
"prettier-plugin-svelte": "^2.6.0",
"sass": "^1.48.0",
"svelte": "^3.46.1",
"svelte-preprocess": "^4.10.1",
"tsm": "^2.2.1",
"tsup": "^5.11.11",
"typescript": "^4.5.4",
"uvu": "^0.5.3"
}
}

@@ -37,5 +37,11 @@ # svelte-preprocess-import-assets

svelte({ preprocess: [importAssets()] })
// or in svelte.config.js
const config = {
preprocess: [importAssets()],
// ... other svelte options
};
```
[Here is more information](https://github.com/sveltejs/svelte-preprocess/blob/9e587151e9384b819d7b285caba7231c138942f0/docs/usage.md) on how to integrate it with your bundler.
[Here is more information](https://github.com/sveltejs/svelte-preprocess/blob/main/docs/usage.md) on how to integrate it with your bundler.

@@ -122,2 +128,12 @@ ## API

### Using with svelte-preprocess
Due to how Svelte applies preprocessors, using this with `svelte-preprocess` needs a bit more work to make sure we run this preprocessor **only after** `svelte-preprocess` finishes. There's [an RFC](https://github.com/sveltejs/rfcs/pull/56) to make this process clearer soon.
At the meantime, you can try one of these libraries:
- [svelte-sequential-preprocessor](https://github.com/pchynoweth/svelte-sequential-preprocessor)
- [svelte-as-markup-preprocessor](https://github.com/firefish5000/svelte-as-markup-preprocessor)
- [My custom gist](https://gist.github.com/bluwy/5fc6f97768b7f065df4e2dbb1366db4c)
## Attributions

@@ -124,0 +140,0 @@

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