rollup-plugin-svelte
Advanced tools
Comparing version 5.0.1 to 5.0.2
43
index.js
@@ -32,3 +32,5 @@ const fs = require('fs'); | ||
extensions: true, | ||
shared: true | ||
shared: true, | ||
emitCss: true, | ||
preprocess: true | ||
}; | ||
@@ -122,3 +124,3 @@ | ||
const fixedOptions = {}; | ||
const fixed_options = {}; | ||
@@ -128,7 +130,12 @@ Object.keys(options).forEach(key => { | ||
if (pluginOptions[key]) return; | ||
fixedOptions[key] = options[key]; | ||
fixed_options[key] = options[key]; | ||
}); | ||
fixedOptions.format = major_version >= 3 ? 'esm' : 'es'; | ||
fixedOptions.shared = require.resolve(options.shared || (major_version >= 3 ? 'svelte/internal.js' : 'svelte/shared.js')); | ||
if (major_version >= 3) { | ||
fixed_options.format = 'esm'; | ||
fixed_options.sveltePath = options.sveltePath || 'svelte'; | ||
} else { | ||
fixed_options.format = 'es'; | ||
fixed_options.shared = require.resolve(options.shared || 'svelte/shared.js'); | ||
} | ||
@@ -149,7 +156,7 @@ // handle CSS extraction | ||
if (css || options.emitCss) { | ||
fixedOptions.css = false; | ||
fixed_options.css = false; | ||
} | ||
if (options.onwarn) { | ||
fixedOptions.onwarn = options.onwarn; | ||
fixed_options.onwarn = options.onwarn; | ||
} | ||
@@ -226,10 +233,13 @@ | ||
return preprocessPromise.then(code => { | ||
let warnings = []; | ||
const base_options = major_version < 3 | ||
? { | ||
onwarn: warning => warnings.push(warning) | ||
} | ||
: {}; | ||
const compiled = compile( | ||
code, | ||
Object.assign({}, { | ||
onwarn: warning => { | ||
if ((options.css || !options.emitCss) && warning.code === 'css-unused-selector') return; | ||
this.warn(warning); | ||
} | ||
}, fixedOptions, { | ||
Object.assign(base_options, fixed_options, { | ||
name: capitalize(sanitize(id)), | ||
@@ -240,2 +250,9 @@ filename: id | ||
if (major_version >= 3) warnings = compiled.warnings || compiled.stats.warnings; | ||
warnings.forEach(warning => { | ||
if ((options.css || !options.emitCss) && warning.code === 'css-unused-selector') return; | ||
this.warn(warning); | ||
}); | ||
if ((css || options.emitCss) && compiled.css.code) { | ||
@@ -242,0 +259,0 @@ let fname = id.replace(extension, '.css'); |
{ | ||
"name": "rollup-plugin-svelte", | ||
"version": "5.0.1", | ||
"version": "5.0.2", | ||
"description": "Compile Svelte components with Rollup", | ||
@@ -34,3 +34,3 @@ "main": "index.js", | ||
"source-map": "^0.6.1", | ||
"svelte": "^3.0.0-alpha2" | ||
"svelte": "^3.0.0-beta.5" | ||
}, | ||
@@ -37,0 +37,0 @@ "dependencies": { |
@@ -30,8 +30,8 @@ # rollup-plugin-svelte | ||
svelte({ | ||
// By default, all .html and .svelte files are compiled | ||
extensions: [ '.my-custom-extension' ], | ||
// By default, all .svelte and .html files are compiled | ||
extensions: ['.my-custom-extension'], | ||
// You can restrict which files are compiled | ||
// using `include` and `exclude` | ||
include: 'src/components/**/*.html', | ||
include: 'src/components/**/*.svelte', | ||
@@ -82,4 +82,4 @@ // By default, the client-side compiler is used. You | ||
// this means 'some-component' resolves to 'some-component/src/SomeComponent.html' | ||
"svelte": "src/MyComponent.html" | ||
// this means 'some-component' resolves to 'some-component/src/SomeComponent.svelte' | ||
"svelte": "src/MyComponent.svelte" | ||
} | ||
@@ -86,0 +86,0 @@ ``` |
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
16795
261