vue-loader
Advanced tools
Comparing version 16.0.0-beta.5 to 16.0.0-beta.6
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.genCSSModulesCode = void 0; | ||
function genCSSModulesCode(id, index, request, moduleName, needsHotReload) { | ||
@@ -4,0 +5,0 @@ const styleVar = `style${index}`; |
import { CompilerError } from '@vue/compiler-sfc'; | ||
export declare function formatError(err: CompilerError, source: string, file: string): void; | ||
export declare function formatError(err: SyntaxError | CompilerError, source: string, file: string): void; |
@@ -6,12 +6,15 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.formatError = void 0; | ||
const compiler_sfc_1 = require("@vue/compiler-sfc"); | ||
const chalk_1 = __importDefault(require("chalk")); | ||
function formatError(err, source, file) { | ||
if (err.loc) { | ||
const loc = `:${err.loc.start.line}:${err.loc.start.column}`; | ||
const filePath = chalk_1.default.gray(`at ${file}${loc}`); | ||
const codeframe = compiler_sfc_1.generateCodeFrame(source, err.loc.start.offset, err.loc.end.offset); | ||
err.message = `\n${chalk_1.default.red(`VueCompilerError: ${err.message}`)}\n${filePath}\n${chalk_1.default.yellow(codeframe)}\n`; | ||
const loc = err.loc; | ||
if (!loc) { | ||
return; | ||
} | ||
const locString = `:${loc.start.line}:${loc.start.column}`; | ||
const filePath = chalk_1.default.gray(`at ${file}${locString}`); | ||
const codeframe = compiler_sfc_1.generateCodeFrame(source, loc.start.offset, loc.end.offset); | ||
err.message = `\n${chalk_1.default.red(`VueCompilerError: ${err.message}`)}\n${filePath}\n${chalk_1.default.yellow(codeframe)}\n`; | ||
} | ||
exports.formatError = formatError; |
"use strict"; | ||
// __VUE_HMR_RUNTIME__ is injected to global scope by @vue/runtime-core | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.genHotReloadCode = void 0; | ||
function genHotReloadCode(id, templateRequest) { | ||
@@ -5,0 +6,0 @@ return ` |
import webpack from 'webpack'; | ||
import { TemplateCompiler, CompilerOptions, SFCTemplateCompileOptions } from '@vue/compiler-sfc'; | ||
import { TemplateCompiler, CompilerOptions, SFCTemplateCompileOptions, SFCScriptCompileOptions } from '@vue/compiler-sfc'; | ||
import VueLoaderPlugin from './plugin'; | ||
export { VueLoaderPlugin }; | ||
export interface VueLoaderOptions { | ||
babelParserPlugins?: SFCScriptCompileOptions['babelParserPlugins']; | ||
transformAssetUrls?: SFCTemplateCompileOptions['transformAssetUrls']; | ||
@@ -7,0 +8,0 @@ compiler?: TemplateCompiler | string; |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.VueLoaderPlugin = void 0; | ||
try { | ||
@@ -73,2 +74,25 @@ require.resolve('@vue/compiler-sfc'); | ||
options.hotReload !== false; | ||
// script | ||
let script; | ||
let scriptImport = `const script = {}`; | ||
if (descriptor.script || descriptor.scriptSetup) { | ||
try { | ||
script = descriptor.scriptCompiled = compiler_sfc_1.compileScript(descriptor, { | ||
babelParserPlugins: options.babelParserPlugins | ||
}); | ||
} | ||
catch (e) { | ||
loaderContext.emitError(e); | ||
} | ||
if (script) { | ||
const src = script.src || resourcePath; | ||
const attrsQuery = attrsToQuery(script.attrs, 'js'); | ||
const query = `?vue&type=script${attrsQuery}${resourceQuery}`; | ||
const scriptRequest = stringifyRequest(src + query); | ||
scriptImport = | ||
`import script from ${scriptRequest}\n` + | ||
// support named exports | ||
`export * from ${scriptRequest}`; | ||
} | ||
} | ||
// template | ||
@@ -82,16 +106,9 @@ let templateImport = ``; | ||
const attrsQuery = attrsToQuery(descriptor.template.attrs); | ||
const query = `?vue&type=template${idQuery}${scopedQuery}${attrsQuery}${resourceQuery}`; | ||
const bindingsQuery = script | ||
? `&bindings=${JSON.stringify(script.bindings)}` | ||
: ``; | ||
const query = `?vue&type=template${idQuery}${scopedQuery}${attrsQuery}${bindingsQuery}${resourceQuery}`; | ||
templateRequest = stringifyRequest(src + query); | ||
templateImport = `import { render } from ${templateRequest}`; | ||
} | ||
// script | ||
let scriptImport = `const script = {}`; | ||
if (descriptor.script) { | ||
const src = descriptor.script.src || resourcePath; | ||
const attrsQuery = attrsToQuery(descriptor.script.attrs, 'js'); | ||
const query = `?vue&type=script${attrsQuery}${resourceQuery}`; | ||
const scriptRequest = stringifyRequest(src + query); | ||
scriptImport = | ||
`import script from ${scriptRequest}\n` + `export * from ${scriptRequest}`; // support named exports | ||
} | ||
// styles | ||
@@ -98,0 +115,0 @@ let stylesCode = ``; |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.pitch = void 0; | ||
const querystring_1 = __importDefault(require("querystring")); | ||
@@ -8,0 +9,0 @@ const loader_utils_1 = __importDefault(require("loader-utils")); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.selectBlock = void 0; | ||
function selectBlock(descriptor, loaderContext, query, appendExtension) { | ||
@@ -17,3 +18,3 @@ // template | ||
if (query.type === `script`) { | ||
const script = descriptor.script; | ||
const script = descriptor.scriptCompiled; | ||
if (appendExtension) { | ||
@@ -20,0 +21,0 @@ loaderContext.resourcePath += '.' + (script.lang || 'js'); |
@@ -19,2 +19,3 @@ "use strict"; | ||
scoped: !!query.scoped, | ||
vars: !!query.vars, | ||
trim: true | ||
@@ -21,0 +22,0 @@ }); |
@@ -37,3 +37,3 @@ "use strict"; | ||
compiler, | ||
compilerOptions: Object.assign(Object.assign({}, options.compilerOptions), { scopeId }), | ||
compilerOptions: Object.assign(Object.assign({}, options.compilerOptions), { scopeId, bindingMetadata: JSON.parse(query.bindings) }), | ||
transformAssetUrls: options.transformAssetUrls || true | ||
@@ -40,0 +40,0 @@ }); |
{ | ||
"name": "vue-loader", | ||
"version": "16.0.0-beta.5", | ||
"version": "16.0.0-beta.6", | ||
"license": "MIT", | ||
@@ -51,3 +51,3 @@ "author": "Evan You", | ||
"@types/webpack-merge": "^4.1.5", | ||
"@vue/compiler-sfc": "^3.0.0-beta.9", | ||
"@vue/compiler-sfc": "^3.0.0-rc.10", | ||
"babel-loader": "^8.0.6", | ||
@@ -57,3 +57,3 @@ "cache-loader": "^4.1.0", | ||
"file-loader": "^5.0.2", | ||
"jest": "^25.5.4", | ||
"jest": "^26.4.1", | ||
"lint-staged": "^9.5.0", | ||
@@ -67,6 +67,6 @@ "memfs": "^3.1.2", | ||
"stylus-loader": "^3.0.2", | ||
"ts-jest": "^25.5.1", | ||
"typescript": "^3.7.3", | ||
"ts-jest": "^26.2.0", | ||
"typescript": "^4.0.2", | ||
"url-loader": "^3.0.0", | ||
"vue": "^3.0.0-beta.9", | ||
"vue": "^3.0.0-rc.10", | ||
"webpack": "^4.41.2", | ||
@@ -73,0 +73,0 @@ "webpack-cli": "^3.3.10", |
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
47381
29
917