Socket
Socket
Sign inDemoInstall

rollup-plugin-vue

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-vue - npm Package Compare versions

Comparing version 6.0.0-beta.1 to 6.0.0-beta.2

1

dist/index.d.ts

@@ -8,2 +8,3 @@ import { SFCTemplateCompileOptions, SFCStyleCompileOptions } from '@vue/compiler-sfc';

exposeFilename: boolean;
customBlocks?: string[];
preprocessStyles?: boolean;

@@ -10,0 +11,0 @@ cssModulesOptions?: {

@@ -26,2 +26,3 @@ "use strict";

exposeFilename: false,
customBlocks: [],
};

@@ -37,13 +38,20 @@ function PluginVue(userOptions = {}) {

const filter = rollup_pluginutils_1.createFilter(options.include, options.exclude);
const filterCustomBlock = createCustomBlockFilter(options.customBlocks);
return {
name: 'vue',
resolveId(id, importer) {
async resolveId(id, importer) {
const query = parseVuePartRequest(id);
if (query.vue) {
if (query.src) {
id = path_1.resolve(path_1.dirname(importer), id);
// map src request to the importer vue file descriptor
const [filename] = id.split('?', 2);
cache.set(filename, getDescriptor(importer));
const resolved = await this.resolve(query.filename, importer, {
skipSelf: true,
});
if (resolved) {
cache.set(resolved.id, getDescriptor(importer));
}
return resolved;
}
else if (!filter(query.filename)) {
return undefined;
}
debug(`resolveId(${id})`);

@@ -84,2 +92,4 @@ return id;

if (query.vue) {
if (!filter(query.filename))
return null;
const descriptor = getDescriptor(query.filename);

@@ -166,3 +176,3 @@ const hasScoped = descriptor.styles.some((s) => s.scoped);

// module id for scoped CSS & hot-reload
const output = transformVueSFC(code, id, descriptor, { rootContext, isProduction, isServer }, options);
const output = transformVueSFC(code, id, descriptor, { rootContext, isProduction, isServer, filterCustomBlock }, options);
debug('transient .vue file:', '\n' + output + '\n');

@@ -183,2 +193,18 @@ return {

exports.default = PluginVue;
function createCustomBlockFilter(queries) {
if (!queries || queries.length === 0)
return () => false;
const allowed = new Set(queries.filter((query) => /^[a-z]/i.test(query)));
const disallowed = new Set(queries
.filter((query) => /^![a-z]/i.test(query))
.map((query) => query.substr(1)));
const allowAll = queries.includes('*') || !queries.includes('!*');
return (type) => {
if (allowed.has(type))
return true;
if (disallowed.has(type))
return true;
return allowAll;
};
}
function parseVuePartRequest(id) {

@@ -218,3 +244,3 @@ const [filename, query] = id.split('?', 2);

}
function transformVueSFC(code, resourcePath, descriptor, { rootContext, isProduction, isServer, }, options) {
function transformVueSFC(code, resourcePath, descriptor, { rootContext, isProduction, isServer, filterCustomBlock, }, options) {
const shortFilePath = path_1.relative(rootContext, resourcePath)

@@ -229,2 +255,3 @@ .replace(/^(\.\.[\/\\])+/, '')

const stylesCode = getStyleCode(descriptor, resourcePath, id, options.preprocessStyles);
const customBlocksCode = getCustomBlock(descriptor, resourcePath, filterCustomBlock);
const output = [

@@ -234,2 +261,3 @@ scriptImport,

stylesCode,
customBlocksCode,
isServer ? `script.ssrRender = ssrRender` : `script.render = render`,

@@ -286,3 +314,3 @@ ];

const attrsQuery = attrsToQuery(style.attrs, 'css', preprocessStyles);
const attrsQueryWithoutModule = attrsQuery.replace(/&module(=true)?/, '');
const attrsQueryWithoutModule = attrsQuery.replace(/&module(=true|=[^&]+)?/, '');
// make sure to only pass id when necessary so that we don't inject

@@ -310,2 +338,17 @@ // duplicate tags when multiple components import the same css file

}
function getCustomBlock(descriptor, resourcePath, filter) {
let code = '';
descriptor.customBlocks.forEach((block, index) => {
if (filter(block.type)) {
const src = block.src || resourcePath;
const attrsQuery = attrsToQuery(block.attrs, block.type);
const srcQuery = block.src ? `&src` : ``;
const query = `?vue&type=${block.type}&index=${index}${srcQuery}${attrsQuery}`;
const request = _(src + query);
code += `import block${index} from ${request}\n`;
code += `if (typeof block${index} === 'function') block${index}(script)\n`;
}
});
return code;
}
function createRollupError(id, error) {

@@ -330,3 +373,3 @@ return {

// if the user happen to add them as attrs
const ignoreList = ['id', 'index', 'src', 'type'];
const ignoreList = ['id', 'index', 'src', 'type', 'lang'];
function attrsToQuery(attrs, langFallback, forceLangFallback = false) {

@@ -340,8 +383,8 @@ let query = ``;

}
if (langFallback) {
if (langFallback || attrs.lang) {
query +=
`lang` in attrs
? forceLangFallback
? `.${langFallback}`
: ``
? `&lang.${langFallback}`
: `&lang.${attrs.lang}`
: `&lang.${langFallback}`;

@@ -348,0 +391,0 @@ }

15

package.json
{
"name": "rollup-plugin-vue",
"version": "6.0.0-beta.1",
"version": "6.0.0-beta.2",
"license": "MIT",

@@ -14,3 +14,6 @@ "main": "dist/index.js",

"prepublishOnly": "tsc -p .",
"dev": "tsc -w -p ."
"dev": "tsc -w -p .",
"test": "run-p test:*",
"test:unit": "jest",
"test:e2e": "jest --config jest.e2e.config.js"
},

@@ -27,9 +30,13 @@ "dependencies": {

"@types/debug": "^4.1.5",
"@types/jest": "^25.2.3",
"@types/node": "^13.13.2",
"@vue/compiler-sfc": "^3.0.0-beta.9",
"@vue/compiler-sfc": "^3.0.0-beta.14",
"husky": "^4.2.0",
"jest": "^26.0.1",
"lint-staged": "^10.1.7",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.5",
"rollup": "^2.7.2",
"typescript": "^3.7.5"
"ts-jest": "^26.0.0",
"typescript": "^3.9.3"
},

@@ -36,0 +43,0 @@ "husky": {

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