svelte-preprocess-import-assets
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -1,4 +0,31 @@ | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/index.ts | ||
var _compiler = require('svelte/compiler'); | ||
var _magicstring = require('magic-string'); var _magicstring2 = _interopRequireDefault(_magicstring); | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
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 __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, {get: all[name], enumerable: true}); | ||
}; | ||
var __reExport = (target, module2, 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}); | ||
} | ||
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); | ||
}; | ||
// src/index.ts | ||
__markAsModule(exports); | ||
__export(exports, { | ||
default: () => importAssets | ||
}); | ||
var import_compiler = __toModule(require("svelte/compiler")); | ||
var import_magic_string = __toModule(require("magic-string")); | ||
function importAssets(options = {}) { | ||
@@ -16,4 +43,4 @@ let { | ||
markup({content, filename}) { | ||
const s = new (0, _magicstring2.default)(content); | ||
const ast = _compiler.parse.call(void 0, content, {filename}); | ||
const s = new import_magic_string.default(content); | ||
const ast = (0, import_compiler.parse)(content, {filename}); | ||
const imports = new Map(); | ||
@@ -36,3 +63,3 @@ function addImport(attributeValue) { | ||
let ignoreNextElement = false; | ||
_compiler.walk.call(void 0, ast.html, { | ||
(0, import_compiler.walk)(ast.html, { | ||
enter(node) { | ||
@@ -68,3 +95,3 @@ var _a, _b; | ||
return; | ||
if (attribute.value.length > 1 && attribute.value[0].type !== "Text") | ||
if (attribute.value.length !== 1 || attribute.value[0].type !== "Text") | ||
return; | ||
@@ -244,4 +271,3 @@ if (source.filter && !source.filter({ | ||
]; | ||
exports.default = importAssets; | ||
// 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.2", | ||
"version": "0.1.3", | ||
"license": "MIT", | ||
@@ -11,4 +11,7 @@ "author": "Bjorn Lu", | ||
"exports": { | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.js" | ||
"./package.json": "./package.json", | ||
".": { | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.js" | ||
} | ||
}, | ||
@@ -32,2 +35,9 @@ "files": [ | ||
], | ||
"scripts": { | ||
"build": "tsc && tsup src/index.ts --dts --no-splitting --format esm,cjs", | ||
"test": "esno test/index.ts", | ||
"test:update": "esno test/index.ts -u", | ||
"format": "prettier -w {src,test}/**/*.{ts,svelte}", | ||
"prepublishOnly": "rm -rf dist && pnpm build" | ||
}, | ||
"dependencies": { | ||
@@ -48,9 +58,3 @@ "magic-string": "^0.25.7" | ||
"uvu": "^0.5.1" | ||
}, | ||
"scripts": { | ||
"build": "tsc && tsup src/index.ts --dts --format esm,cjs", | ||
"test": "esno test/index.ts", | ||
"test:update": "esno test/index.ts -u", | ||
"format": "prettier -w {src,test}/**/*.{ts,svelte}" | ||
} | ||
} | ||
} |
# svelte-preprocess-import-assets | ||
Import assets directly in your markup. | ||
Import assets directly in the markup. | ||
@@ -5,0 +5,0 @@ **Convert this:** |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19922
533
5