@mpxjs/webpack-plugin 2.6.114-alpha.8 → 2.6.115

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.
Files changed (129) hide show
  1. package/README.md +1 -1
  2. package/lib/built-in-loader.js +49 -0
  3. package/lib/config.js +0 -14
  4. package/lib/content-loader.js +13 -0
  5. package/lib/dependency/ChildCompileDependency.js +24 -0
  6. package/lib/dependency/InjectDependency.js +26 -0
  7. package/lib/dependency/RemovedModuleDependency.js +23 -0
  8. package/lib/{dependencies → dependency}/ReplaceDependency.js +2 -19
  9. package/lib/dependency/ResolveDependency.js +49 -0
  10. package/lib/extractor.js +178 -82
  11. package/lib/file-loader.js +19 -7
  12. package/lib/helpers.js +334 -39
  13. package/lib/index.js +525 -889
  14. package/lib/json-compiler/index.js +451 -245
  15. package/lib/json-compiler/{theme.js → theme-loader.js} +3 -5
  16. package/lib/loader.js +241 -178
  17. package/lib/native-loader.js +133 -71
  18. package/lib/parser.js +2 -1
  19. package/lib/path-loader.js +3 -0
  20. package/lib/platform/json/wx/index.js +1 -1
  21. package/lib/platform/template/normalize-component-rules.js +3 -2
  22. package/lib/platform/template/wx/component-config/button.js +2 -14
  23. package/lib/platform/template/wx/component-config/image.js +0 -4
  24. package/lib/platform/template/wx/component-config/input.js +0 -4
  25. package/lib/platform/template/wx/component-config/rich-text.js +0 -4
  26. package/lib/platform/template/wx/component-config/scroll-view.js +0 -4
  27. package/lib/platform/template/wx/component-config/switch.js +0 -4
  28. package/lib/platform/template/wx/component-config/text.js +0 -4
  29. package/lib/platform/template/wx/component-config/textarea.js +0 -5
  30. package/lib/platform/template/wx/component-config/view.js +0 -4
  31. package/lib/platform/template/wx/index.js +3 -149
  32. package/lib/plugin-loader.js +287 -0
  33. package/lib/resolver/AddEnvPlugin.js +3 -4
  34. package/lib/resolver/AddModePlugin.js +3 -4
  35. package/lib/resolver/PackageEntryPlugin.js +36 -23
  36. package/lib/runtime/base.styl +0 -5
  37. package/lib/runtime/components/web/getInnerListeners.js +3 -1
  38. package/lib/runtime/components/web/mpx-image.vue +5 -20
  39. package/lib/runtime/components/web/mpx-movable-view.vue +2 -6
  40. package/lib/runtime/components/web/mpx-swiper.vue +3 -18
  41. package/lib/runtime/i18n.wxs +11 -31
  42. package/lib/runtime/optionProcessor.js +3 -48
  43. package/lib/selector.js +10 -29
  44. package/lib/staticConfig.js +4 -0
  45. package/lib/style-compiler/index.js +24 -16
  46. package/lib/style-compiler/load-postcss-config.js +1 -3
  47. package/lib/style-compiler/plugins/conditional-strip.js +65 -68
  48. package/lib/style-compiler/plugins/rpx.js +37 -43
  49. package/lib/style-compiler/plugins/scope-id.js +72 -79
  50. package/lib/style-compiler/plugins/trans-special.js +18 -25
  51. package/lib/style-compiler/plugins/trim.js +7 -13
  52. package/lib/style-compiler/plugins/vw.js +16 -22
  53. package/lib/template-compiler/compiler.js +199 -106
  54. package/lib/template-compiler/index.js +139 -52
  55. package/lib/template-compiler/trans-dynamic-class-expr.js +13 -18
  56. package/lib/url-loader.js +29 -11
  57. package/lib/utils/add-query.js +1 -1
  58. package/lib/utils/get-main-compilation.js +6 -0
  59. package/lib/utils/is-url-request.js +1 -10
  60. package/lib/utils/match-condition.js +1 -4
  61. package/lib/utils/normalize.js +15 -4
  62. package/lib/utils/parse-request.js +3 -3
  63. package/lib/utils/read-json-for-src.js +34 -0
  64. package/lib/utils/stringify-query.js +0 -4
  65. package/lib/utils/try-require.js +16 -0
  66. package/lib/web/processJSON.js +144 -113
  67. package/lib/web/processScript.js +34 -47
  68. package/lib/web/processTemplate.js +40 -57
  69. package/lib/wxml/{loader.js → wxml-loader.js} +62 -21
  70. package/lib/wxs/WxsParserPlugin.js +2 -2
  71. package/lib/wxs/WxsPlugin.js +8 -4
  72. package/lib/wxs/WxsTemplatePlugin.js +92 -46
  73. package/lib/wxs/{i18n-loader.js → wxs-i18n-loader.js} +4 -5
  74. package/lib/wxs/wxs-loader.js +117 -0
  75. package/lib/wxs/{pre-loader.js → wxs-pre-loader.js} +5 -20
  76. package/lib/wxss/getImportPrefix.js +30 -0
  77. package/lib/wxss/loader.js +43 -31
  78. package/lib/wxss/localsLoader.js +5 -1
  79. package/lib/wxss/processCss.js +103 -107
  80. package/package.json +18 -21
  81. package/LICENSE +0 -433
  82. package/lib/dependencies/AddEntryDependency.js +0 -24
  83. package/lib/dependencies/AppEntryDependency.js +0 -58
  84. package/lib/dependencies/CommonJsAsyncDependency.js +0 -51
  85. package/lib/dependencies/CommonJsVariableDependency.js +0 -81
  86. package/lib/dependencies/DynamicEntryDependency.js +0 -171
  87. package/lib/dependencies/FlagPluginDependency.js +0 -24
  88. package/lib/dependencies/InjectDependency.js +0 -43
  89. package/lib/dependencies/RecordGlobalComponentsDependency.js +0 -50
  90. package/lib/dependencies/RecordIndependentDependency.js +0 -44
  91. package/lib/dependencies/RecordResourceMapDependency.js +0 -62
  92. package/lib/dependencies/RemoveEntryDependency.js +0 -40
  93. package/lib/dependencies/ResolveDependency.js +0 -88
  94. package/lib/independent-loader.js +0 -52
  95. package/lib/json-compiler/helper.js +0 -156
  96. package/lib/json-compiler/plugin.js +0 -150
  97. package/lib/partial-compile/index.js +0 -35
  98. package/lib/record-loader.js +0 -11
  99. package/lib/resolve-loader.js +0 -6
  100. package/lib/resolver/FixDescriptionInfoPlugin.js +0 -28
  101. package/lib/runtime/components/tenon/getInnerListeners.js +0 -317
  102. package/lib/runtime/components/tenon/tenon-button.vue +0 -305
  103. package/lib/runtime/components/tenon/tenon-image.vue +0 -61
  104. package/lib/runtime/components/tenon/tenon-input.vue +0 -99
  105. package/lib/runtime/components/tenon/tenon-rich-text.vue +0 -21
  106. package/lib/runtime/components/tenon/tenon-scroll-view.vue +0 -124
  107. package/lib/runtime/components/tenon/tenon-switch.vue +0 -91
  108. package/lib/runtime/components/tenon/tenon-text-area.vue +0 -64
  109. package/lib/runtime/components/tenon/tenon-text.vue +0 -64
  110. package/lib/runtime/components/tenon/tenon-view.vue +0 -93
  111. package/lib/runtime/components/tenon/util.js +0 -44
  112. package/lib/runtime/optionProcessor.tenon.js +0 -386
  113. package/lib/style-compiler/plugins/hm.js +0 -20
  114. package/lib/tenon/index.js +0 -105
  115. package/lib/tenon/processJSON.js +0 -360
  116. package/lib/tenon/processScript.js +0 -260
  117. package/lib/tenon/processStyles.js +0 -21
  118. package/lib/tenon/processTemplate.js +0 -133
  119. package/lib/utils/const.js +0 -10
  120. package/lib/utils/emit-file.js +0 -10
  121. package/lib/utils/eval-json-js.js +0 -31
  122. package/lib/utils/get-entry-name.js +0 -13
  123. package/lib/utils/get-json-content.js +0 -42
  124. package/lib/utils/get-relative-path.js +0 -24
  125. package/lib/utils/resolve.js +0 -13
  126. package/lib/utils/set.js +0 -47
  127. package/lib/utils/stringify-loaders-resource.js +0 -25
  128. package/lib/wxs/WxsModuleIdsPlugin.js +0 -29
  129. package/lib/wxs/loader.js +0 -142
@@ -2,20 +2,21 @@ const babylon = require('@babel/parser')
2
2
  const traverse = require('@babel/traverse').default
3
3
  const t = require('@babel/types')
4
4
  const generate = require('@babel/generator').default
5
+ const getMainCompilation = require('../utils/get-main-compilation')
5
6
  const parseRequest = require('../utils/parse-request')
6
7
  const isEmptyObject = require('../utils/is-empty-object')
7
8
  const parseQuery = require('loader-utils').parseQuery
8
9
 
9
10
  module.exports = function (content) {
10
11
  this.cacheable()
11
- const mpx = this.getMpx()
12
+ const mainCompilation = getMainCompilation(this._compilation)
12
13
  const module = this._module
13
- const mode = mpx.mode
14
+ const mode = mainCompilation.__mpx__.mode
14
15
  const wxsModule = parseQuery(this.resourceQuery || '?').wxsModule
15
16
 
16
17
  // 处理内联wxs
17
18
  if (wxsModule) {
18
- const wxsContentMap = mpx.wxsContentMap
19
+ const wxsContentMap = mainCompilation.__mpx__.wxsContentMap
19
20
  const resourcePath = parseRequest(this.resource).resourcePath
20
21
  content = wxsContentMap[`${resourcePath}~${wxsModule}`] || content
21
22
  }
@@ -44,15 +45,6 @@ module.exports = function (content) {
44
45
  }
45
46
  }
46
47
  },
47
- CallExpression (path) {
48
- const callee = path.node.callee
49
- if (t.isIdentifier(callee) && callee.name === 'getRegExp') {
50
- const argPath = path.get('arguments')[0]
51
- if (argPath.isStringLiteral()) {
52
- argPath.replaceWith(t.stringLiteral(argPath.node.extra.raw.slice(1, -1)))
53
- }
54
- }
55
- },
56
48
  ForStatement (path) {
57
49
  if (path.shouldStopTraverse) {
58
50
  path.stop()
@@ -101,19 +93,12 @@ module.exports = function (content) {
101
93
  },
102
94
  CallExpression (path) {
103
95
  const callee = path.node.callee
104
- const args = path.node.arguments
105
96
  const transMap = {
106
97
  getDate: 'Date',
107
98
  getRegExp: 'RegExp'
108
99
  }
109
100
  if (t.isIdentifier(callee) && transMap[callee.name]) {
110
- if (callee.name === 'getRegExp') {
111
- const arg = args[0]
112
- if (t.isStringLiteral(arg)) {
113
- args[0] = t.stringLiteral(arg.extra.raw.slice(1, -1))
114
- }
115
- }
116
- path.replaceWith(t.newExpression(t.identifier(transMap[callee.name]), args))
101
+ path.replaceWith(t.newExpression(t.identifier(transMap[callee.name]), path.node.arguments))
117
102
  }
118
103
  }
119
104
  })
@@ -0,0 +1,30 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ Modified by @hiyuki
5
+ */
6
+ const normalize = require('../utils/normalize')
7
+ const extractorPath = normalize.lib('extractor')
8
+ const toPosix = require('../utils/to-posix')
9
+
10
+ module.exports = function getImportPrefix (loaderContext, extract) {
11
+ const selectorIndex = loaderContext.loaders.findIndex(({ path }) => {
12
+ // 兼容windows路径
13
+ return toPosix(path).indexOf('@mpxjs/webpack-plugin/lib/selector') !== -1
14
+ })
15
+ let loadersRequest = loaderContext.loaders.slice(
16
+ loaderContext.loaderIndex,
17
+ selectorIndex !== -1 ? selectorIndex : undefined
18
+ ).map(function (x) {
19
+ return x.request
20
+ }).join('!')
21
+ if (extract) {
22
+ loadersRequest = extractorPath + '?' +
23
+ JSON.stringify({
24
+ type: 'styles',
25
+ index: -1,
26
+ fromImport: true
27
+ }) + '!' + loadersRequest
28
+ }
29
+ return '-!' + loadersRequest + '!'
30
+ }
@@ -5,22 +5,25 @@
5
5
  */
6
6
  const loaderUtils = require('loader-utils')
7
7
  const processCss = require('./processCss')
8
+ const getImportPrefix = require('./getImportPrefix')
8
9
  const compileExports = require('./compile-exports')
9
10
  const createResolver = require('./createResolver')
10
11
  const isUrlRequest = require('../utils/is-url-request')
11
- const createHelpers = require('../helpers')
12
+ const getMainCompilation = require('../utils/get-main-compilation')
13
+ const addQuery = require('../utils/add-query')
12
14
 
13
15
  module.exports = function (content, map) {
14
16
  if (this.cacheable) this.cacheable()
17
+
15
18
  const callback = this.async()
16
19
  const query = loaderUtils.getOptions(this) || {}
20
+ const root = query.root
17
21
  const moduleMode = query.modules || query.module
18
22
  const camelCaseKeys = query.camelCase || query.camelcase
23
+ const sourceMap = this.sourceMap || false
19
24
  const resolve = createResolver(query.alias)
20
- const mpx = this.getMpx()
25
+ const mpx = getMainCompilation(this._compilation).__mpx__
21
26
  const externals = mpx.externals
22
- const root = mpx.projectRoot
23
- const sourceMap = mpx.cssSourceMap || false
24
27
 
25
28
  if (sourceMap) {
26
29
  if (map) {
@@ -40,24 +43,25 @@ module.exports = function (content, map) {
40
43
  map = null
41
44
  }
42
45
 
43
- const { getRequestString } = createHelpers(this)
44
-
45
46
  processCss(content, map, {
46
47
  mode: moduleMode ? 'local' : 'global',
47
48
  from: loaderUtils.getRemainingRequest(this).split('!').pop(),
48
49
  to: loaderUtils.getCurrentRequest(this).split('!').pop(),
49
- query,
50
- resolve,
50
+ query: query,
51
+ resolve: resolve,
51
52
  minimize: this.minimize,
52
53
  loaderContext: this,
53
- sourceMap
54
- }, (err, result) => {
54
+ sourceMap: sourceMap
55
+ }, function (err, result) {
55
56
  if (err) return callback(err)
56
57
 
57
58
  let cssAsString = JSON.stringify(result.source)
58
59
 
60
+ // for importing CSS
61
+ const importUrlPrefix = getImportPrefix(this)
62
+
59
63
  const alreadyImported = {}
60
- const importJs = result.importItems.filter((imp) => {
64
+ const importJs = result.importItems.filter(function (imp) {
61
65
  if (!imp.mediaQuery) {
62
66
  if (alreadyImported[imp.url]) {
63
67
  return false
@@ -65,35 +69,43 @@ module.exports = function (content, map) {
65
69
  alreadyImported[imp.url] = true
66
70
  }
67
71
  return true
68
- }).map((imp, i) => {
69
- if (!isUrlRequest(imp.url, root, externals)) {
72
+ }).map(function (imp) {
73
+ if (!isUrlRequest(imp.url, root) || externals.some((external) => {
74
+ if (typeof external === 'string') {
75
+ return external === imp.url
76
+ } else if (external instanceof RegExp) {
77
+ return external.test(imp.url)
78
+ }
79
+ return false
80
+ })) {
70
81
  return 'exports.push([module.id, ' +
71
82
  JSON.stringify('@import url(' + imp.url + ');') + ', ' +
72
83
  JSON.stringify(imp.mediaQuery) + ']);'
73
84
  } else {
74
- const requestString = getRequestString('styles', { src: imp.url }, {
75
- isStatic: true,
76
- issuerResource: this.resource,
77
- fromImport: true
78
- }, i)
79
- return 'exports.push([module.id, ' +
80
- JSON.stringify('@import "') +
81
- '+ require(' + requestString + ') +' +
82
- JSON.stringify('";') + ', ' +
83
- JSON.stringify(imp.mediaQuery) + ']);'
85
+ if (query.extract) {
86
+ const importUrlPrefix = getImportPrefix(this, true)
87
+ const importUrl = importUrlPrefix + addQuery(imp.url, { isStatic: true, issuerResource: this.resource })
88
+ return 'exports.push([module.id, ' +
89
+ JSON.stringify('@import "') +
90
+ '+ require(' + loaderUtils.stringifyRequest(this, importUrl) + ') +' +
91
+ JSON.stringify('";') + ', ' +
92
+ JSON.stringify(imp.mediaQuery) + ']);'
93
+ }
94
+ const importUrl = importUrlPrefix + imp.url
95
+ return 'exports.i(require(' + loaderUtils.stringifyRequest(this, importUrl) + '), ' + JSON.stringify(imp.mediaQuery) + ');'
84
96
  }
85
- }).join('\n')
97
+ }, this).join('\n')
86
98
 
87
- const importItemMatcher = (item) => {
99
+ function importItemMatcher (item) {
88
100
  const match = result.importItemRegExp.exec(item)
89
101
  const idx = +match[1]
90
102
  const importItem = result.importItems[idx]
91
- const importUrl = importItem.url
103
+ const importUrl = importUrlPrefix + importItem.url
92
104
  return '" + require(' + loaderUtils.stringifyRequest(this, importUrl) + ').locals' +
93
105
  '[' + JSON.stringify(importItem.export) + '] + "'
94
106
  }
95
107
 
96
- cssAsString = cssAsString.replace(result.importItemRegExpG, importItemMatcher)
108
+ cssAsString = cssAsString.replace(result.importItemRegExpG, importItemMatcher.bind(this))
97
109
 
98
110
  // helper for ensuring valid CSS strings from requires
99
111
  let urlEscapeHelper = ''
@@ -101,7 +113,7 @@ module.exports = function (content, map) {
101
113
  if (query.url !== false && result.urlItems.length > 0) {
102
114
  urlEscapeHelper = 'var escape = require(' + loaderUtils.stringifyRequest(this, '!!' + require.resolve('./url/escape.js')) + ');\n'
103
115
 
104
- cssAsString = cssAsString.replace(result.urlItemRegExpG, (item) => {
116
+ cssAsString = cssAsString.replace(result.urlItemRegExpG, function (item) {
105
117
  const match = result.urlItemRegExp.exec(item)
106
118
  let idx = +match[1]
107
119
  const urlItem = result.urlItems[idx]
@@ -117,10 +129,10 @@ module.exports = function (content, map) {
117
129
  }
118
130
  urlRequest = url
119
131
  return '" + escape(require(' + loaderUtils.stringifyRequest(this, urlRequest) + ')) + "'
120
- })
132
+ }.bind(this))
121
133
  }
122
134
 
123
- let exportJs = compileExports(result, importItemMatcher, camelCaseKeys)
135
+ let exportJs = compileExports(result, importItemMatcher.bind(this), camelCaseKeys)
124
136
  if (exportJs) {
125
137
  exportJs = 'exports.locals = ' + exportJs + ';'
126
138
  }
@@ -153,5 +165,5 @@ module.exports = function (content, map) {
153
165
  moduleJs + '\n\n' +
154
166
  '// exports\n' +
155
167
  exportJs)
156
- })
168
+ }.bind(this))
157
169
  }
@@ -5,6 +5,7 @@
5
5
  */
6
6
  var loaderUtils = require('loader-utils')
7
7
  var processCss = require('./processCss')
8
+ var getImportPrefix = require('./getImportPrefix')
8
9
  var compileExports = require('./compile-exports')
9
10
  var createResolver = require('./createResolver')
10
11
 
@@ -25,11 +26,14 @@ module.exports = function (content) {
25
26
  }, function (err, result) {
26
27
  if (err) return callback(err)
27
28
 
29
+ // for importing CSS
30
+ var importUrlPrefix = getImportPrefix(this, query)
31
+
28
32
  function importItemMatcher (item) {
29
33
  var match = result.importItemRegExp.exec(item)
30
34
  var idx = +match[1]
31
35
  var importItem = result.importItems[idx]
32
- var importUrl = importItem.url
36
+ var importUrl = importUrlPrefix + importItem.url
33
37
  return '" + require(' + loaderUtils.stringifyRequest(this, importUrl) + ')' +
34
38
  '[' + JSON.stringify(importItem.export) + '] + "'
35
39
  }
@@ -17,133 +17,129 @@ const modulesScope = require('postcss-modules-scope')
17
17
  const modulesValues = require('postcss-modules-values')
18
18
  const valueParser = require('postcss-value-parser')
19
19
  const isUrlRequest = require('../utils/is-url-request')
20
- // css-loader-parser
21
20
 
22
- const parserPlugin = function (options) {
23
- return {
24
- postcssPlugin: 'css-loader-parser',
25
- Once (css) {
26
- const imports = {}
27
- let exports = {}
28
- const importItems = []
29
- const urlItems = []
30
-
31
- function replaceImportsInString (str) {
32
- if (options.import) {
33
- const tokens = valueParser(str)
34
- tokens.walk(function (node) {
35
- if (node.type !== 'word') {
36
- return
37
- }
38
- const token = node.value
39
- const importIndex = imports['$' + token]
40
- if (typeof importIndex === 'number') {
41
- node.value = '___CSS_LOADER_IMPORT___' + importIndex + '___'
42
- }
43
- })
44
- return tokens.toString()
45
- }
46
- return str
47
- }
21
+ const parserPlugin = postcss.plugin('css-loader-parser', function (options) {
22
+ return function (css) {
23
+ const imports = {}
24
+ let exports = {}
25
+ const importItems = []
26
+ const urlItems = []
48
27
 
28
+ function replaceImportsInString (str) {
49
29
  if (options.import) {
50
- css.walkAtRules(/^import$/i, function (rule) {
51
- const values = Tokenizer.parseValues(rule.params)
52
- let url = values.nodes[0].nodes[0]
53
- if (url && url.type === 'url') {
54
- url = url.url
55
- } else if (url && url.type === 'string') {
56
- url = url.value
57
- } else throw rule.error('Unexpected format ' + rule.params)
58
- if (!url.replace(/\s/g, '').length) {
30
+ const tokens = valueParser(str)
31
+ tokens.walk(function (node) {
32
+ if (node.type !== 'word') {
59
33
  return
60
34
  }
61
- values.nodes[0].nodes.shift()
62
- const mediaQuery = Tokenizer.stringifyValues(values)
63
-
64
- if (isUrlRequest(url, options.root)) {
65
- url = loaderUtils.urlToRequest(url, options.root)
35
+ const token = node.value
36
+ const importIndex = imports['$' + token]
37
+ if (typeof importIndex === 'number') {
38
+ node.value = '___CSS_LOADER_IMPORT___' + importIndex + '___'
66
39
  }
67
-
68
- importItems.push({
69
- url: url,
70
- mediaQuery: mediaQuery
71
- })
72
- rule.remove()
73
40
  })
41
+ return tokens.toString()
74
42
  }
43
+ return str
44
+ }
45
+
46
+ if (options.import) {
47
+ css.walkAtRules(/^import$/i, function (rule) {
48
+ const values = Tokenizer.parseValues(rule.params)
49
+ let url = values.nodes[0].nodes[0]
50
+ if (url && url.type === 'url') {
51
+ url = url.url
52
+ } else if (url && url.type === 'string') {
53
+ url = url.value
54
+ } else throw rule.error('Unexpected format ' + rule.params)
55
+ if (!url.replace(/\s/g, '').length) {
56
+ return
57
+ }
58
+ values.nodes[0].nodes.shift()
59
+ const mediaQuery = Tokenizer.stringifyValues(values)
75
60
 
76
- const icss = icssUtils.extractICSS(css)
77
- exports = icss.icssExports
78
- Object.keys(icss.icssImports).forEach(function (key) {
79
- const url = loaderUtils.parseString(key)
80
- Object.keys(icss.icssImports[key]).forEach(function (prop) {
81
- imports['$' + prop] = importItems.length
82
- importItems.push({
83
- url: url,
84
- export: icss.icssImports[key][prop]
85
- })
61
+ if (isUrlRequest(url, options.root)) {
62
+ url = loaderUtils.urlToRequest(url, options.root)
63
+ }
64
+
65
+ importItems.push({
66
+ url: url,
67
+ mediaQuery: mediaQuery
86
68
  })
69
+ rule.remove()
87
70
  })
71
+ }
88
72
 
89
- Object.keys(exports).forEach(function (exportName) {
90
- exports[exportName] = replaceImportsInString(exports[exportName])
73
+ const icss = icssUtils.extractICSS(css)
74
+ exports = icss.icssExports
75
+ Object.keys(icss.icssImports).forEach(function (key) {
76
+ const url = loaderUtils.parseString(key)
77
+ Object.keys(icss.icssImports[key]).forEach(function (prop) {
78
+ imports['$' + prop] = importItems.length
79
+ importItems.push({
80
+ url: url,
81
+ export: icss.icssImports[key][prop]
82
+ })
91
83
  })
84
+ })
92
85
 
93
- function isAlias (url) {
94
- // Handle alias starting by / and root disabled
95
- return url !== options.resolve(url)
96
- }
86
+ Object.keys(exports).forEach(function (exportName) {
87
+ exports[exportName] = replaceImportsInString(exports[exportName])
88
+ })
97
89
 
98
- function processNode (item) {
99
- switch (item.type) {
100
- case 'value':
101
- item.nodes.forEach(processNode)
102
- break
103
- case 'nested-item':
104
- item.nodes.forEach(processNode)
105
- break
106
- case 'item':
107
- const importIndex = imports['$' + item.name]
108
- if (typeof importIndex === 'number') {
109
- item.name = '___CSS_LOADER_IMPORT___' + importIndex + '___'
110
- }
111
- break
112
- case 'url':
113
- if (options.url && item.url.replace(/\s/g, '').length && !/^#/.test(item.url) && (isAlias(item.url) || isUrlRequest(item.url, options.root))) {
114
- // Strip quotes, they will be re-added if the module needs them
115
- item.stringType = ''
116
- delete item.innerSpacingBefore
117
- delete item.innerSpacingAfter
118
- const url = item.url
119
- item.url = '___CSS_LOADER_URL___' + urlItems.length + '___'
120
- urlItems.push({
121
- url: url
122
- })
123
- }
124
- break
125
- }
90
+ function isAlias (url) {
91
+ // Handle alias starting by / and root disabled
92
+ return url !== options.resolve(url)
93
+ }
94
+
95
+ function processNode (item) {
96
+ switch (item.type) {
97
+ case 'value':
98
+ item.nodes.forEach(processNode)
99
+ break
100
+ case 'nested-item':
101
+ item.nodes.forEach(processNode)
102
+ break
103
+ case 'item':
104
+ const importIndex = imports['$' + item.name]
105
+ if (typeof importIndex === 'number') {
106
+ item.name = '___CSS_LOADER_IMPORT___' + importIndex + '___'
107
+ }
108
+ break
109
+ case 'url':
110
+ if (options.url && item.url.replace(/\s/g, '').length && !/^#/.test(item.url) && (isAlias(item.url) || isUrlRequest(item.url, options.root))) {
111
+ // Strip quotes, they will be re-added if the module needs them
112
+ item.stringType = ''
113
+ delete item.innerSpacingBefore
114
+ delete item.innerSpacingAfter
115
+ const url = item.url
116
+ item.url = '___CSS_LOADER_URL___' + urlItems.length + '___'
117
+ urlItems.push({
118
+ url: url
119
+ })
120
+ }
121
+ break
126
122
  }
123
+ }
127
124
 
128
- css.walkDecls(function (decl) {
129
- const values = Tokenizer.parseValues(decl.value)
130
- values.nodes.forEach(function (value) {
131
- value.nodes.forEach(processNode)
132
- })
133
- decl.value = Tokenizer.stringifyValues(values)
134
- })
135
- css.walkAtRules(function (atrule) {
136
- if (typeof atrule.params === 'string') {
137
- atrule.params = replaceImportsInString(atrule.params)
138
- }
125
+ css.walkDecls(function (decl) {
126
+ const values = Tokenizer.parseValues(decl.value)
127
+ values.nodes.forEach(function (value) {
128
+ value.nodes.forEach(processNode)
139
129
  })
130
+ decl.value = Tokenizer.stringifyValues(values)
131
+ })
132
+ css.walkAtRules(function (atrule) {
133
+ if (typeof atrule.params === 'string') {
134
+ atrule.params = replaceImportsInString(atrule.params)
135
+ }
136
+ })
140
137
 
141
- options.importItems = importItems
142
- options.urlItems = urlItems
143
- options.exports = exports
144
- }
138
+ options.importItems = importItems
139
+ options.urlItems = urlItems
140
+ options.exports = exports
145
141
  }
146
- }
142
+ })
147
143
 
148
144
  module.exports = function processCss (inputSource, inputMap, options, callback) {
149
145
  const query = options.query
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.6.114-alpha.8",
3
+ "version": "2.6.115",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
@@ -27,15 +27,12 @@
27
27
  "@better-scroll/slide": "^2.2.1",
28
28
  "@better-scroll/wheel": "^2.2.1",
29
29
  "@better-scroll/zoom": "^2.2.1",
30
- "@hummer/tenon-dev-server-webpack-plugin": "0.0.2",
31
- "@hummer/tenon-loader": "^1.1.0",
32
- "@hummer/tenon-style-loader": "^0.2.0",
33
30
  "acorn-walk": "^7.2.0",
34
31
  "async": "^2.6.0",
35
32
  "consolidate": "^0.15.1",
36
33
  "css": "^2.2.1",
37
34
  "css-selector-tokenizer": "^0.7.0",
38
- "cssnano": "^5.0.16",
35
+ "cssnano": "^3.10.0",
39
36
  "de-indent": "^1.0.2",
40
37
  "fastparse": "^1.1.1",
41
38
  "hash-sum": "^1.0.2",
@@ -43,24 +40,28 @@
43
40
  "html-minifier": "^3.5.8",
44
41
  "icss-utils": "^2.1.0",
45
42
  "json5": "^2.1.3",
46
- "loader-utils": "^2.0.2",
43
+ "loader-utils": "1.1.0",
47
44
  "lodash": "^4.17.15",
48
45
  "lodash.camelcase": "^4.3.0",
49
46
  "lru-cache": "^4.1.2",
50
47
  "mime": "^2.2.2",
51
48
  "object-assign": "^4.1.1",
52
- "postcss": "^8.4.5",
53
- "postcss-load-config": "^3.1.1",
54
- "postcss-modules-extract-imports": "^3.0.0",
55
- "postcss-modules-local-by-default": "^4.0.0",
56
- "postcss-modules-scope": "^3.0.0",
57
- "postcss-modules-values": "^4.0.0",
58
- "postcss-selector-parser": "^6.0.8",
59
- "postcss-value-parser": "^4.0.2",
60
- "source-list-map": "^2.0.0"
49
+ "postcss": "^6.0.19",
50
+ "postcss-load-config": "^1.2.0",
51
+ "postcss-modules-extract-imports": "^1.2.0",
52
+ "postcss-modules-local-by-default": "^1.2.0",
53
+ "postcss-modules-scope": "^1.1.0",
54
+ "postcss-modules-values": "^1.3.0",
55
+ "postcss-selector-parser": "^2.0.0",
56
+ "postcss-value-parser": "^3.3.0",
57
+ "resolve": "^1.5.0",
58
+ "source-list-map": "^2.0.0",
59
+ "webpack-sources": "^1.1.0"
61
60
  },
62
61
  "peerDependencies": {
63
- "webpack": "^5.48.0"
62
+ "css-loader": "^0.28.10",
63
+ "webpack": "^4.0.0",
64
+ "webpack-cli": "^3.0.0"
64
65
  },
65
66
  "publishConfig": {
66
67
  "registry": "https://registry.npmjs.org"
@@ -79,9 +80,5 @@
79
80
  "devDependencies": {
80
81
  "@types/babel-traverse": "^6.25.4",
81
82
  "@types/babel-types": "^7.0.4"
82
- },
83
- "engines": {
84
- "node": ">=14.14.0"
85
- },
86
- "gitHead": "f6a3d039dbe797630651f9d945b8755a5f05e528"
83
+ }
87
84
  }