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

rollup-plugin-svelte

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-svelte - npm Package Compare versions

Comparing version 4.1.0 to 4.2.0

4

CHANGELOG.md
# rollup-plugin-svelte changelog
## 4.2.0
* Add `emitCss` option ([#32](https://github.com/rollup/rollup-plugin-svelte/pull/32))
## 4.1.0

@@ -4,0 +8,0 @@

63

dist/rollup-plugin-svelte.cjs.js

@@ -45,3 +45,3 @@ 'use strict';

} catch (err) {
if (err.code === 'MODULE_NOT_FOUND') { return null; }
if (err.code === 'MODULE_NOT_FOUND') return null;
throw err;

@@ -56,3 +56,3 @@ }

} catch (err) {
if (err.code === 'ENOENT') { return false; }
if (err.code === 'ENOENT') return false;
throw err;

@@ -64,3 +64,3 @@ }

const parent = path.dirname(dir);
if (parent === dir) { return; }
if (parent === dir) return;

@@ -72,3 +72,3 @@ mkdirp(parent);

} catch (err) {
if (err.code !== 'EEXIST') { throw err; }
if (err.code !== 'EEXIST') throw err;
}

@@ -117,5 +117,3 @@ }

function svelte$1(options) {
if ( options === void 0 ) options = {};
function svelte$1(options = {}) {
const filter = rollupPluginutils.createFilter(options.include, options.exclude);

@@ -129,3 +127,3 @@

// add all options except include, exclude, extensions, and shared
if (pluginOptions[key]) { return; }
if (pluginOptions[key]) return;
fixedOptions[key] = options[key];

@@ -147,5 +145,6 @@ });

: null;
const cssLookup = new Map();
if (css) {
if (css || options.emitCss) {
fixedOptions.css = false;

@@ -161,5 +160,11 @@ }

load(id) {
if (!cssLookup.has(id)) return null;
return cssLookup.get(id);
},
resolveId(importee, importer) {
if (cssLookup.has(importee)) { return importee; }
if (!importer || importee[0] === '.' || importee[0] === '\0' || path.isAbsolute(importee))
{ return null; }
return null;

@@ -169,3 +174,3 @@ // if this is a bare import, see if there's a valid pkg.svelte

let name = parts.shift();
if (name[0] === '@') { name += `/${parts.shift()}`; }
if (name[0] === '@') name += `/${parts.shift()}`;

@@ -176,5 +181,5 @@ const resolved = tryResolve(

);
if (!resolved) { return null; }
if (!resolved) return null;
const pkg = tryRequire(resolved);
if (!pkg) { return null; }
if (!pkg) return null;

@@ -190,4 +195,5 @@ const dir = path.dirname(resolved);

if (pkg['svelte.root']) {
// TODO remove this. it's weird and unnecessary
const sub = path.resolve(dir, pkg['svelte.root'], parts.join('/'));
if (exists(sub)) { return sub; }
if (exists(sub)) return sub;
}

@@ -198,4 +204,4 @@ }

transform(code, id) {
if (!filter(id)) { return null; }
if (!~extensions.indexOf(path.extname(id))) { return null; }
if (!filter(id)) return null;
if (!~extensions.indexOf(path.extname(id))) return null;

@@ -207,4 +213,3 @@ return (options.preprocess ? svelte.preprocess(code, Object.assign({}, options.preprocess, { filename : id })) : Promise.resolve(code)).then(code => {

onwarn: warning => {
// TODO replace this with warning.code, post sveltejs/svelte#824
if (options.css === false && warning.message === 'Unused CSS selector') { return; }
if ((options.css || !options.emitCss) && warning.code === 'css-unused-selector') return;
this.warn(warning);

@@ -219,17 +224,14 @@ },

if (css) {
// handle pre- and post-1.60 signature
const code = typeof compiled.css === 'string' ? compiled.css : compiled.css && compiled.css.code;
const map = compiled.css && compiled.css.map || compiled.cssMap;
if (css || options.emitCss) {
let fname = id.replace('.html', '.css');
cssLookup.set(fname, compiled.css);
if (options.emitCss) {
compiled.js.code += `\nimport '${fname}';\n`;
}
cssLookup.set(id, { code, map });
}
return {
code: compiled.js ? compiled.js.code : compiled.code,
map: compiled.js ? compiled.js.map : compiled.map
};
return compiled.js;
});
},
ongenerate() {

@@ -246,4 +248,3 @@ if (css) {

for (let chunk of cssLookup.values()) {
if (!chunk.code) { continue; }
if (!chunk.code) continue;
result += chunk.code + '\n';

@@ -266,3 +267,3 @@

mappings.push.apply(mappings, decoded);
mappings.push(...decoded);
}

@@ -269,0 +270,0 @@ }

@@ -6,3 +6,3 @@ import fs from 'fs';

import { createFilter } from 'rollup-pluginutils';
import { decode, encode } from 'sourcemap-codec';
import { encode, decode } from 'sourcemap-codec';

@@ -42,3 +42,3 @@ function sanitize(input) {

} catch (err) {
if (err.code === 'MODULE_NOT_FOUND') { return null; }
if (err.code === 'MODULE_NOT_FOUND') return null;
throw err;

@@ -53,3 +53,3 @@ }

} catch (err) {
if (err.code === 'ENOENT') { return false; }
if (err.code === 'ENOENT') return false;
throw err;

@@ -61,3 +61,3 @@ }

const parent = path.dirname(dir);
if (parent === dir) { return; }
if (parent === dir) return;

@@ -69,3 +69,3 @@ mkdirp(parent);

} catch (err) {
if (err.code !== 'EEXIST') { throw err; }
if (err.code !== 'EEXIST') throw err;
}

@@ -114,5 +114,3 @@ }

function svelte$1(options) {
if ( options === void 0 ) options = {};
function svelte(options = {}) {
const filter = createFilter(options.include, options.exclude);

@@ -126,3 +124,3 @@

// add all options except include, exclude, extensions, and shared
if (pluginOptions[key]) { return; }
if (pluginOptions[key]) return;
fixedOptions[key] = options[key];

@@ -144,5 +142,6 @@ });

: null;
const cssLookup = new Map();
if (css) {
if (css || options.emitCss) {
fixedOptions.css = false;

@@ -158,5 +157,11 @@ }

load(id) {
if (!cssLookup.has(id)) return null;
return cssLookup.get(id);
},
resolveId(importee, importer) {
if (cssLookup.has(importee)) { return importee; }
if (!importer || importee[0] === '.' || importee[0] === '\0' || path.isAbsolute(importee))
{ return null; }
return null;

@@ -166,3 +171,3 @@ // if this is a bare import, see if there's a valid pkg.svelte

let name = parts.shift();
if (name[0] === '@') { name += `/${parts.shift()}`; }
if (name[0] === '@') name += `/${parts.shift()}`;

@@ -173,5 +178,5 @@ const resolved = tryResolve(

);
if (!resolved) { return null; }
if (!resolved) return null;
const pkg = tryRequire(resolved);
if (!pkg) { return null; }
if (!pkg) return null;

@@ -187,4 +192,5 @@ const dir = path.dirname(resolved);

if (pkg['svelte.root']) {
// TODO remove this. it's weird and unnecessary
const sub = path.resolve(dir, pkg['svelte.root'], parts.join('/'));
if (exists(sub)) { return sub; }
if (exists(sub)) return sub;
}

@@ -195,4 +201,4 @@ }

transform(code, id) {
if (!filter(id)) { return null; }
if (!~extensions.indexOf(path.extname(id))) { return null; }
if (!filter(id)) return null;
if (!~extensions.indexOf(path.extname(id))) return null;

@@ -204,4 +210,3 @@ return (options.preprocess ? preprocess(code, Object.assign({}, options.preprocess, { filename : id })) : Promise.resolve(code)).then(code => {

onwarn: warning => {
// TODO replace this with warning.code, post sveltejs/svelte#824
if (options.css === false && warning.message === 'Unused CSS selector') { return; }
if ((options.css || !options.emitCss) && warning.code === 'css-unused-selector') return;
this.warn(warning);

@@ -216,17 +221,14 @@ },

if (css) {
// handle pre- and post-1.60 signature
const code = typeof compiled.css === 'string' ? compiled.css : compiled.css && compiled.css.code;
const map = compiled.css && compiled.css.map || compiled.cssMap;
if (css || options.emitCss) {
let fname = id.replace('.html', '.css');
cssLookup.set(fname, compiled.css);
if (options.emitCss) {
compiled.js.code += `\nimport '${fname}';\n`;
}
cssLookup.set(id, { code, map });
}
return {
code: compiled.js ? compiled.js.code : compiled.code,
map: compiled.js ? compiled.js.map : compiled.map
};
return compiled.js;
});
},
ongenerate() {

@@ -243,4 +245,3 @@ if (css) {

for (let chunk of cssLookup.values()) {
if (!chunk.code) { continue; }
if (!chunk.code) continue;
result += chunk.code + '\n';

@@ -263,3 +264,3 @@

mappings.push.apply(mappings, decoded);
mappings.push(...decoded);
}

@@ -280,2 +281,2 @@ }

export default svelte$1;
export default svelte;
{
"name": "rollup-plugin-svelte",
"version": "4.1.0",
"version": "4.2.0",
"description": "Compile Svelte components with Rollup",

@@ -16,3 +16,3 @@ "main": "dist/rollup-plugin-svelte.cjs.js",

"pretest": "npm run build",
"prepublish": "npm run lint && npm run build",
"prepublishOnly": "npm run lint && npm run build",
"build": "rollup -c",

@@ -34,16 +34,15 @@ "dev": "rollup -c -w",

"devDependencies": {
"eslint": "^4.12.1",
"locate-character": "^2.0.3",
"mocha": "^4.0.1",
"rollup": "^0.52.0",
"rollup-plugin-buble": "^0.18.0",
"eslint": "^5.0.1",
"locate-character": "^2.0.5",
"mocha": "^5.2.0",
"rollup": "^0.62.0",
"rollup-watch": "^4.3.1",
"sander": "^0.6.0",
"source-map": "^0.6.1",
"svelte": "^1.60.0"
"svelte": "^2.9.1"
},
"dependencies": {
"require-relative": "^0.8.7",
"rollup-pluginutils": "^2.0.1",
"sourcemap-codec": "^1.3.1"
"rollup-pluginutils": "^2.3.0",
"sourcemap-codec": "^1.4.1"
},

@@ -50,0 +49,0 @@ "peerDependencies": {

@@ -65,5 +65,5 @@ # rollup-plugin-svelte

## `pkg.svelte` and `pkg["svelte.root"]`
## `pkg.svelte`
If you're importing a component from your node_modules folder, and that component's package.json has `"svelte"` and/or `"svelte.root"` properties...
If you're importing a component from your node_modules folder, and that component's package.json has a `"svelte"` property...

@@ -75,6 +75,3 @@ ```js

// this means 'some-component' resolves to 'some-component/src/SomeComponent.html'
"svelte": "src/MyComponent.html",
// this means 'my-component/Foo.html' resolves to 'some-component/src/Foo.html'
"svelte.root": "src"
"svelte": "src/MyComponent.html"
}

@@ -85,3 +82,3 @@ ```

Conversely, if you're *publishing* a component to npm, you should ship the uncompiled source (together with the compiled distributable, for people who aren't using Svelte elsewhere in their app) and include these properties in your package.json.
Conversely, if you're *publishing* a component to npm, you should ship the uncompiled source (together with the compiled distributable, for people who aren't using Svelte elsewhere in their app) and include the `"svelte"` property in your package.json.

@@ -88,0 +85,0 @@

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