@mpxjs/webpack-plugin 2.7.58 → 2.7.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/loader.js CHANGED
@@ -18,15 +18,17 @@ const AppEntryDependency = require('./dependencies/AppEntryDependency')
18
18
  const RecordResourceMapDependency = require('./dependencies/RecordResourceMapDependency')
19
19
  const RecordVueContentDependency = require('./dependencies/RecordVueContentDependency')
20
20
  const CommonJsVariableDependency = require('./dependencies/CommonJsVariableDependency')
21
+ const tsWatchRunLoaderFilter = require('./utils/ts-loader-watch-run-loader-filter')
21
22
  const { MPX_APP_MODULE_ID } = require('./utils/const')
22
23
  const path = require('path')
23
24
 
24
25
  module.exports = function (content) {
25
26
  this.cacheable()
26
27
 
27
- // 兼容处理处理ts-loader中watch-run/updateFile逻辑,直接跳过当前loader及后续的vue-loader返回内容
28
- if (path.extname(this.resourcePath) === '.ts') {
29
- this.loaderIndex -= 2
28
+ // 兼容处理处理ts-loader中watch-run/updateFile逻辑,直接跳过当前loader及后续的loader返回内容
29
+ const pathExtname = path.extname(this.resourcePath)
30
+ if (!['.vue', '.mpx'].includes(pathExtname)) {
31
+ this.loaderIndex = tsWatchRunLoaderFilter(this.loaders, this.loaderIndex)
30
32
  return content
31
33
  }
32
34
 
package/lib/selector.js CHANGED
@@ -1,9 +1,15 @@
1
1
  const parseComponent = require('./parser')
2
2
  const parseRequest = require('./utils/parse-request')
3
+ const tsWatchRunLoaderFilter = require('./utils/ts-loader-watch-run-loader-filter')
4
+ const path = require('path')
3
5
 
4
6
  module.exports = function (content) {
5
7
  this.cacheable()
6
-
8
+ const pathExtname = path.extname(this.resourcePath)
9
+ if (!['.vue', '.mpx'].includes(pathExtname)) {
10
+ this.loaderIndex = tsWatchRunLoaderFilter(this.loaders, this.loaderIndex)
11
+ return content
12
+ }
7
13
  // 移除mpx访问依赖,支持 thread-loader
8
14
  const { mode, env } = this.getOptions() || {}
9
15
  if (!mode && !env) {
package/lib/url-loader.js CHANGED
@@ -3,24 +3,15 @@ const mime = require('mime')
3
3
  const parseRequest = require('./utils/parse-request')
4
4
  const getOptions = loaderUtils.getOptions
5
5
 
6
- function isStyleRequest (request) {
7
- const { loaderString, queryObj } = parseRequest(request)
8
- if (queryObj.type === 'styles') return true
9
- if (/(css-loader|wxss\/loader)/.test(loaderString)) return true
10
- return false
11
- }
12
-
13
6
  module.exports = function (src) {
14
7
  let transBase64 = false
15
8
  const options = Object.assign({}, getOptions(this))
16
9
  const { resourcePath, queryObj } = parseRequest(this.resource)
17
10
  const mimetype = options.mimetype || mime.getType(resourcePath)
18
- const moduleGraph = this._compilation.moduleGraph
19
- const issuer = moduleGraph.getIssuer(this._module)
20
11
  const publicPathScope = options.publicPathScope === 'all' ? 'all' : 'styleOnly'
21
12
  const limit = options.limit
22
13
  const useLocal = !limit || src.length < limit || queryObj.useLocal
23
- const isStyle = (issuer && issuer.request && isStyleRequest(issuer.request)) || queryObj.isStyle
14
+ const isStyle = queryObj.isStyle
24
15
 
25
16
  if (isStyle) {
26
17
  if (options.publicPath) {
@@ -4,7 +4,7 @@ module.exports = function (loaderContext) {
4
4
  let entryName = ''
5
5
  for (const [name, { dependencies }] of loaderContext._compilation.entries) {
6
6
  const entryModule = moduleGraph.getModule(dependencies[0])
7
- if (entryModule.resource === loaderContext.resource) {
7
+ if (entryModule && entryModule.resource === loaderContext.resource) {
8
8
  entryName = name
9
9
  break
10
10
  }
@@ -0,0 +1,23 @@
1
+ const normalize = require('./normalize')
2
+ const selectorPath = normalize.lib('selector.js')
3
+ const scriptSetupPath = normalize.lib('script-setup-compiler/index.js')
4
+ const mpxLoaderPath = normalize.lib('loader.js')
5
+ const { has } = require('./set')
6
+
7
+ const tsLoaderWatchRunFilterLoaders = new Set([
8
+ selectorPath,
9
+ scriptSetupPath,
10
+ mpxLoaderPath,
11
+ 'node_modules/vue-loader/lib/index.js'
12
+ ])
13
+
14
+ module.exports = (loaders, loaderIndex) => {
15
+ for (let len = loaders.length; len > 0; --len) {
16
+ const currentLoader = loaders[len - 1]
17
+ if (!has(tsLoaderWatchRunFilterLoaders, filterLoaderPath => currentLoader.path.endsWith(filterLoaderPath))) {
18
+ break
19
+ }
20
+ loaderIndex--
21
+ }
22
+ return loaderIndex
23
+ }
@@ -8,6 +8,8 @@ const {
8
8
  WEBPACK_IGNORE_COMMENT_REGEXP
9
9
  } = require('../utils')
10
10
 
11
+ const addQuery = require('../../utils/add-query')
12
+
11
13
  const isUrlFunc = /url/i
12
14
  const isImageSetFunc = /^(?:-webkit-)?image-set$/i
13
15
  const needParseDeclaration = /(?:url|(?:-webkit-)?image-set)\(/i
@@ -402,13 +404,13 @@ const plugin = (options = {}) => {
402
404
  if (!importName) {
403
405
  importName = `___CSS_LOADER_URL_IMPORT_${urlToNameMap.size}___`
404
406
  urlToNameMap.set(newUrl, importName)
405
-
407
+ const finalUrl = addQuery(newUrl, { isStyle: true })
406
408
  options.imports.push({
407
409
  type: 'url',
408
410
  importName,
409
411
  url: options.resolver
410
- ? options.urlHandler(newUrl)
411
- : JSON.stringify(newUrl),
412
+ ? options.urlHandler(finalUrl)
413
+ : JSON.stringify(finalUrl),
412
414
  index
413
415
  })
414
416
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.7.58",
3
+ "version": "2.7.60",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
@@ -80,5 +80,5 @@
80
80
  "engines": {
81
81
  "node": ">=14.14.0"
82
82
  },
83
- "gitHead": "bb48b5989cd2c89ba464ac1ee53529431d56fb33"
83
+ "gitHead": "72ac7dda91b406492c0f58eb64034cb5d0bd0fe2"
84
84
  }