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 2.0.3 to 3.0.0

4

CHANGELOG.md
# rollup-plugin-svelte changelog
## 3.0.0
* CSS sourcemaps ([#14](https://github.com/rollup/rollup-plugin-svelte/issues/14))
## 2.0.3

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

@@ -10,2 +10,3 @@ 'use strict';

var rollupPluginutils = require('rollup-pluginutils');
var sourcemapCodec = require('sourcemap-codec');

@@ -59,2 +60,55 @@ function sanitize(input) {

function mkdirp(dir) {
const parent = path.dirname(dir);
if (parent === dir) { return; }
mkdirp(parent);
try {
fs.mkdirSync(dir);
} catch (err) {
if (err.code !== 'EEXIST') { throw err; }
}
}
class CssWriter {
constructor (code, map) {
this.code = code;
this.map = {
version: 3,
file: null,
sources: map.sources,
sourcesContent: map.sourcesContent,
names: [],
mappings: map.mappings
};
}
write(dest, map) {
dest = path.resolve(dest);
mkdirp(path.dirname(dest));
const basename = path.basename(dest);
if (map !== false) {
fs.writeFileSync(dest, `${this.code}\n/*# sourceMappingURL=${basename}.map */`);
fs.writeFileSync(`${dest}.map`, JSON.stringify({
version: 3,
file: basename,
sources: this.map.sources.map(source => path.relative(path.dirname(dest), source)),
sourcesContent: this.map.sourcesContent,
names: [],
mappings: this.map.mappings
}, null, ' '));
} else {
fs.writeFileSync(dest, this.code);
}
}
toString() {
console.log('[DEPRECATION] As of rollup-plugin-svelte@3, the argument to the `css` function is an object, not a string — use `css.write(file)`. Consult the documentation for more information: https://github.com/rollup/rollup-plugin-svelte'); // eslint-disable-line no-console
return this.code;
}
}
function svelte$1(options) {

@@ -151,3 +205,8 @@ if ( options === void 0 ) options = {};

if (css) { cssLookup.set(id, compiled.css); }
if (css) {
cssLookup.set(id, {
code: compiled.css,
map: compiled.cssMap
});
}

@@ -165,7 +224,38 @@ return {

let result = '';
const mappings = [];
const sources = [];
const sourcesContent = [];
for (let chunk of cssLookup.values()) {
result += chunk || '';
if (!chunk.code) { continue; }
result += chunk.code + '\n';
if (chunk.map) {
const i = sources.length;
sources.push(chunk.map.sources[0]);
sourcesContent.push(chunk.map.sourcesContent[0]);
const decoded = sourcemapCodec.decode(chunk.map.mappings);
if (i > 0) {
decoded.forEach(line => {
line.forEach(segment => {
segment[1] = i;
});
});
}
mappings.push.apply(mappings, decoded);
}
}
css(result);
const writer = new CssWriter(result, {
sources,
sourcesContent,
mappings: sourcemapCodec.encode(mappings)
});
css(writer);
}

@@ -172,0 +262,0 @@ }

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

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

@@ -55,2 +56,55 @@ function sanitize(input) {

function mkdirp(dir) {
const parent = path.dirname(dir);
if (parent === dir) { return; }
mkdirp(parent);
try {
fs.mkdirSync(dir);
} catch (err) {
if (err.code !== 'EEXIST') { throw err; }
}
}
class CssWriter {
constructor (code, map) {
this.code = code;
this.map = {
version: 3,
file: null,
sources: map.sources,
sourcesContent: map.sourcesContent,
names: [],
mappings: map.mappings
};
}
write(dest, map) {
dest = path.resolve(dest);
mkdirp(path.dirname(dest));
const basename = path.basename(dest);
if (map !== false) {
fs.writeFileSync(dest, `${this.code}\n/*# sourceMappingURL=${basename}.map */`);
fs.writeFileSync(`${dest}.map`, JSON.stringify({
version: 3,
file: basename,
sources: this.map.sources.map(source => path.relative(path.dirname(dest), source)),
sourcesContent: this.map.sourcesContent,
names: [],
mappings: this.map.mappings
}, null, ' '));
} else {
fs.writeFileSync(dest, this.code);
}
}
toString() {
console.log('[DEPRECATION] As of rollup-plugin-svelte@3, the argument to the `css` function is an object, not a string — use `css.write(file)`. Consult the documentation for more information: https://github.com/rollup/rollup-plugin-svelte'); // eslint-disable-line no-console
return this.code;
}
}
function svelte$1(options) {

@@ -147,3 +201,8 @@ if ( options === void 0 ) options = {};

if (css) { cssLookup.set(id, compiled.css); }
if (css) {
cssLookup.set(id, {
code: compiled.css,
map: compiled.cssMap
});
}

@@ -161,7 +220,38 @@ return {

let result = '';
const mappings = [];
const sources = [];
const sourcesContent = [];
for (let chunk of cssLookup.values()) {
result += chunk || '';
if (!chunk.code) { continue; }
result += chunk.code + '\n';
if (chunk.map) {
const i = sources.length;
sources.push(chunk.map.sources[0]);
sourcesContent.push(chunk.map.sourcesContent[0]);
const decoded = decode(chunk.map.mappings);
if (i > 0) {
decoded.forEach(line => {
line.forEach(segment => {
segment[1] = i;
});
});
}
mappings.push.apply(mappings, decoded);
}
}
css(result);
const writer = new CssWriter(result, {
sources,
sourcesContent,
mappings: encode(mappings)
});
css(writer);
}

@@ -168,0 +258,0 @@ }

10

package.json
{
"name": "rollup-plugin-svelte",
"version": "2.0.3",
"version": "3.0.0",
"description": "Compile Svelte components with Rollup",

@@ -34,6 +34,10 @@ "main": "dist/rollup-plugin-svelte.cjs.js",

"eslint": "^3.10.2",
"locate-character": "^2.0.1",
"mocha": "^3.1.2",
"rollup": "^0.41.5",
"rollup-plugin-buble": "^0.15.0",
"rollup-watch": "^3.2.2"
"rollup-watch": "^3.2.2",
"sander": "^0.6.0",
"source-map": "^0.5.6",
"svelte": "^1.25.1"
},

@@ -43,4 +47,4 @@ "dependencies": {

"rollup-pluginutils": "^2.0.1",
"svelte": "^1.11.2"
"sourcemap-codec": "^1.3.1"
}
}

@@ -39,4 +39,9 @@ # rollup-plugin-svelte

// See note below
css: function ( css ) {
fs.writeFileSync( 'public/main.css', css );
css: function (css) {
console.log(css.code); // the concatenated CSS
console.log(css.map); // a sourcemap
// creates `main.css` and `main.css.map` — pass `false`
// as the second argument if you don't want the sourcemap
css.write('public/main.css');
}

@@ -43,0 +48,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