diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fbb1baf9..c0117d045 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [16.8.1](https://github.com/vuejs/vue-loader/compare/v16.8.0...v16.8.1) (2021-09-22) + + +### Bug Fixes + +* fix template options resolving for ts ([91f581b](https://github.com/vuejs/vue-loader/commit/91f581b99644119b68e586a0b642fff3811c8741)) + # [16.8.0](https://github.com/vuejs/vue-loader/compare/v16.7.1...v16.8.0) (2021-09-22) @@ -22,16 +29,6 @@ * remove pure annotation for custom blocks ([cd891e5](https://github.com/vuejs/vue-loader/commit/cd891e593bf7f8aff852f1d47fda2337de661bea)) - -## [16.7.1](https://github.com/vuejs/vue-loader/compare/v16.7.0...v16.7.1) (2021-09-22) - - -### Bug Fixes - -* remove pure annotation for custom blocks ([cd891e5](https://github.com/vuejs/vue-loader/commit/cd891e593bf7f8aff852f1d47fda2337de661bea)) - - - # [16.7.0](https://github.com/vuejs/vue-loader/compare/v16.6.0...v16.7.0) (2021-09-21) @@ -40,16 +37,6 @@ * support optional @vue/compiler-sfc peer dep ([21725a4](https://github.com/vuejs/vue-loader/commit/21725a4ebc9c8d7f8a590d700017759327e21c2e)) - -# [16.7.0](https://github.com/vuejs/vue-loader/compare/v16.6.0...v16.7.0) (2021-09-21) - - -### Features - -* support optional @vue/compiler-sfc peer dep ([21725a4](https://github.com/vuejs/vue-loader/commit/21725a4ebc9c8d7f8a590d700017759327e21c2e)) - - - # [16.6.0](https://github.com/vuejs/vue-loader/compare/v16.5.0...v16.6.0) (2021-09-20) @@ -63,39 +50,12 @@ * support ts in template expressions ([573fbd2](https://github.com/vuejs/vue-loader/commit/573fbd2e72c3246c2daadb8d8c053464c964cfe3)) - -# [16.6.0](https://github.com/vuejs/vue-loader/compare/v16.5.0...v16.6.0) (2021-09-20) - - -### Bug Fixes - -* generate treeshaking friendly code ([11e3cb8](https://github.com/vuejs/vue-loader/commit/11e3cb8a8a4a4e0aedc2978ce6d7e549a61de3d7)) - - -### Features - -* support ts in template expressions ([573fbd2](https://github.com/vuejs/vue-loader/commit/573fbd2e72c3246c2daadb8d8c053464c964cfe3)) - - - -# [16.5.0](https://github.com/vuejs/vue-loader/compare/v16.4.1...v16.5.0) (2021-08-07) - - - # [16.5.0](https://github.com/vuejs/vue-loader/compare/v16.4.1...v16.5.0) (2021-08-07) * Custom Elements mode behavior changed: now only inlines the CSS and no longer exports the custom element constructor (exports the component as in normal mode). Users now need to explicitly call `defineCustomElement` on the component. This allows the custom element to be defined using an async version of the source component. -## [16.4.1](https://github.com/vuejs/vue-loader/compare/v16.4.0...v16.4.1) (2021-08-02) - -### Bug Fixes - -* fix webpack 5.48 compatibility ([b94289c](https://github.com/vuejs/vue-loader/commit/b94289c9fb395556100ec121529dfe676280d3cd)), closes [#1859](https://github.com/vuejs/vue-loader/issues/1859) - - - -## [16.4.1](https://github.com/vuejs/vue-loader/compare/v16.3.3...v16.4.1) (2021-08-02) +## [16.4.1](https://github.com/vuejs/vue-loader/compare/v16.4.0...v16.4.1) (2021-08-02) ### Bug Fixes diff --git a/package.json b/package.json index 85c2b2301..7895ffc66 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-loader", - "version": "16.8.1", + "version": "16.8.2", "license": "MIT", "author": "Evan You", "main": "dist/index.js", diff --git a/src/descriptorCache.ts b/src/descriptorCache.ts index c8df638a7..4c592a0d1 100644 --- a/src/descriptorCache.ts +++ b/src/descriptorCache.ts @@ -1,5 +1,5 @@ import * as fs from 'fs' -import { SFCDescriptor } from '@vue/compiler-sfc' +import type { SFCDescriptor } from '@vue/compiler-sfc' import { compiler } from './compiler' const cache = new Map() diff --git a/src/formatError.ts b/src/formatError.ts index 6ff42aabd..44ea88b66 100644 --- a/src/formatError.ts +++ b/src/formatError.ts @@ -1,4 +1,4 @@ -import { CompilerError } from '@vue/compiler-sfc' +import type { CompilerError } from '@vue/compiler-sfc' import { compiler } from './compiler' import chalk = require('chalk') diff --git a/src/index.ts b/src/index.ts index c93a3c433..d74373ef5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,7 @@ import * as loaderUtils from 'loader-utils' import hash = require('hash-sum') import { compiler } from './compiler' -import { +import type { TemplateCompiler, CompilerOptions, SFCBlock, @@ -51,12 +51,6 @@ export default function loader( ) { const loaderContext = this - if (!/\.vue(\.html)?$/.test(loaderContext.resourcePath)) { - // ts-loader does some really weird stuff which causes vue-loader to - // somehow be applied on non-vue files... ignore them - return source - } - // check if plugin is installed if ( !errorEmitted && diff --git a/src/pluginWebpack4.ts b/src/pluginWebpack4.ts index f4a7f5107..de9841bb3 100644 --- a/src/pluginWebpack4.ts +++ b/src/pluginWebpack4.ts @@ -1,6 +1,6 @@ import * as qs from 'querystring' import webpack = require('webpack') -import { VueLoaderOptions } from './' +import type { VueLoaderOptions } from './' const RuleSet = require('webpack/lib/RuleSet') diff --git a/src/pluginWebpack5.ts b/src/pluginWebpack5.ts index 0334c4bff..0ffec99e5 100644 --- a/src/pluginWebpack5.ts +++ b/src/pluginWebpack5.ts @@ -1,6 +1,6 @@ import * as qs from 'querystring' -import { VueLoaderOptions } from './' -import { RuleSetRule, Compiler, Plugin } from 'webpack' +import type { VueLoaderOptions } from './' +import type { RuleSetRule, Compiler, Plugin } from 'webpack' const id = 'vue-loader-plugin' const NS = 'vue-loader' @@ -98,14 +98,16 @@ class VueLoaderPlugin implements Plugin { static NS = NS apply(compiler: Compiler) { + // @ts-ignore + const normalModule = compiler.webpack.NormalModule || NormalModule + // add NS marker so that the loader can detect and report missing plugin compiler.hooks.compilation.tap(id, (compilation) => { - NormalModule.getCompilationHooks(compilation).loader.tap( - id, - (loaderContext: any) => { + normalModule + .getCompilationHooks(compilation) + .loader.tap(id, (loaderContext: any) => { loaderContext[NS] = true - } - ) + }) }) const rules = compiler.options.module!.rules diff --git a/src/resolveScript.ts b/src/resolveScript.ts index 51b0c5aa7..a606d7669 100644 --- a/src/resolveScript.ts +++ b/src/resolveScript.ts @@ -1,10 +1,10 @@ import webpack = require('webpack') -import { +import type { SFCDescriptor, SFCScriptBlock, TemplateCompiler, } from '@vue/compiler-sfc' -import { VueLoaderOptions } from 'src' +import type { VueLoaderOptions } from 'src' import { resolveTemplateTSOptions } from './util' import { compiler } from './compiler' diff --git a/src/select.ts b/src/select.ts index bde198c40..f8e5b796c 100644 --- a/src/select.ts +++ b/src/select.ts @@ -1,8 +1,8 @@ import webpack = require('webpack') -import { SFCDescriptor } from '@vue/compiler-sfc' -import { ParsedUrlQuery } from 'querystring' +import type { SFCDescriptor } from '@vue/compiler-sfc' +import type { ParsedUrlQuery } from 'querystring' import { resolveScript } from './resolveScript' -import { VueLoaderOptions } from 'src' +import type { VueLoaderOptions } from 'src' export function selectBlock( descriptor: SFCDescriptor, diff --git a/src/templateLoader.ts b/src/templateLoader.ts index 2129ad95e..c1dd5f400 100644 --- a/src/templateLoader.ts +++ b/src/templateLoader.ts @@ -3,7 +3,7 @@ import * as qs from 'querystring' import * as loaderUtils from 'loader-utils' import { VueLoaderOptions } from './' import { formatError } from './formatError' -import { TemplateCompiler } from '@vue/compiler-sfc' +import type { TemplateCompiler } from '@vue/compiler-sfc' import { getDescriptor } from './descriptorCache' import { resolveScript } from './resolveScript' import { resolveTemplateTSOptions } from './util' @@ -16,12 +16,6 @@ const TemplateLoader: webpack.loader.Loader = function (source, inMap) { source = String(source) const loaderContext = this - if (/\.[jt]sx?$/.test(loaderContext.resourcePath)) { - // ts-loader does some really weird stuff which causes vue-loader to - // somehow be applied on non-vue files... ignore them - return source - } - // although this is not the main vue-loader, we can get access to the same // vue-loader options because we've set an ident in the plugin and used that // ident to create the request for this loader in the pitcher. diff --git a/src/util.ts b/src/util.ts index 1387982c5..2e467b9d6 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,5 +1,5 @@ -import { SFCDescriptor, CompilerOptions } from '@vue/compiler-sfc' -import { VueLoaderOptions } from '.' +import type { SFCDescriptor, CompilerOptions } from '@vue/compiler-sfc' +import type { VueLoaderOptions } from '.' export function resolveTemplateTSOptions( descriptor: SFCDescriptor, diff --git a/test/fixtures/process-custom-file/custom-file.svg b/test/fixtures/process-custom-file/custom-file.svg new file mode 100644 index 000000000..7edfe0d23 --- /dev/null +++ b/test/fixtures/process-custom-file/custom-file.svg @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/test/fixtures/process-custom-file/process-custom-file.vue b/test/fixtures/process-custom-file/process-custom-file.vue new file mode 100644 index 000000000..842e42d2d --- /dev/null +++ b/test/fixtures/process-custom-file/process-custom-file.vue @@ -0,0 +1,13 @@ + + \ No newline at end of file diff --git a/test/template.spec.ts b/test/template.spec.ts index a16f8f1ef..52eda51cb 100644 --- a/test/template.spec.ts +++ b/test/template.spec.ts @@ -102,3 +102,21 @@ test('postLoaders support', async () => { // class="red" -> class="green" expect(instance.$el.className).toBe('green') }) + +// #1879 +test('should allow process custom file', async () => { + const { instance } = await mockBundleAndRun({ + entry: 'process-custom-file/process-custom-file.vue', + module: { + rules: [ + { + test: /\.svg$/, + loader: 'vue-loader', + }, + ], + }, + }) + + expect(instance.$el.tagName).toBe('DIV') + expect(instance.$el.innerHTML).toMatch('ProcessedCustomFile') +}) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy