@mpxjs/webpack-plugin 2.8.39 → 2.8.40-test

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 (51) hide show
  1. package/lib/dependencies/CommonJsExtractDependency.js +51 -0
  2. package/lib/dependencies/ResolveDependency.js +11 -9
  3. package/lib/extractor.js +1 -0
  4. package/lib/helpers.js +9 -1
  5. package/lib/index.js +173 -72
  6. package/lib/json-compiler/helper.js +25 -9
  7. package/lib/json-compiler/index.js +77 -28
  8. package/lib/loader.js +3 -10
  9. package/lib/native-loader.js +21 -14
  10. package/lib/platform/json/wx/index.js +65 -2
  11. package/lib/platform/run-rules.js +2 -1
  12. package/lib/platform/template/normalize-component-rules.js +2 -0
  13. package/lib/platform/template/wx/component-config/README.md +1 -1
  14. package/lib/platform/template/wx/component-config/fix-html-tag.js +17 -0
  15. package/lib/platform/template/wx/component-config/hypen-tag-name.js +2 -6
  16. package/lib/platform/template/wx/component-config/index.js +4 -2
  17. package/lib/platform/template/wx/component-config/view.js +0 -11
  18. package/lib/platform/template/wx/index.js +65 -18
  19. package/lib/runtime/base.styl +0 -5
  20. package/lib/runtime/components/web/filterTag.js +9 -30
  21. package/lib/runtime/components/web/getInnerListeners.js +2 -14
  22. package/lib/runtime/components/web/mpx-keep-alive.vue +10 -17
  23. package/lib/runtime/components/web/mpx-movable-view.vue +105 -23
  24. package/lib/runtime/components/web/mpx-picker-view.vue +1 -1
  25. package/lib/runtime/components/web/mpx-scroll-view.vue +69 -23
  26. package/lib/runtime/components/web/mpx-swiper.vue +152 -62
  27. package/lib/runtime/components/web/mpx-video.vue +123 -89
  28. package/lib/runtime/components/web/mpx-web-view.vue +120 -81
  29. package/lib/runtime/components/web/promisify.js +19 -0
  30. package/lib/runtime/components/wx/default-page.mpx +27 -0
  31. package/lib/runtime/optionProcessor.js +12 -18
  32. package/lib/style-compiler/index.js +5 -1
  33. package/lib/template-compiler/bind-this.js +280 -49
  34. package/lib/template-compiler/compiler.js +54 -58
  35. package/lib/template-compiler/index.js +35 -23
  36. package/lib/utils/dom-tag-config.js +115 -0
  37. package/lib/utils/make-map.js +12 -0
  38. package/lib/utils/string.js +7 -1
  39. package/lib/utils/ts-loader-watch-run-loader-filter.js +4 -5
  40. package/lib/web/processJSON.js +35 -0
  41. package/lib/web/processScript.js +7 -4
  42. package/lib/web/processTemplate.js +7 -34
  43. package/package.json +4 -4
  44. package/lib/partial-compile/index.js +0 -35
  45. package/lib/template-compiler/preprocessor.js +0 -29
  46. package/lib/wxss/compile-exports.js +0 -52
  47. package/lib/wxss/createResolver.js +0 -36
  48. package/lib/wxss/css-base.js +0 -79
  49. package/lib/wxss/getLocalIdent.js +0 -25
  50. package/lib/wxss/localsLoader.js +0 -44
  51. package/lib/wxss/processCss.js +0 -274
@@ -1,274 +0,0 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Tobias Koppers @sokra
4
- Modified by @hiyuki
5
- */
6
- const formatCodeFrame = require('@babel/code-frame')
7
- const Tokenizer = require('css-selector-tokenizer')
8
- const postcss = require('postcss')
9
- const loaderUtils = require('loader-utils')
10
- const assign = require('object-assign')
11
- const getLocalIdent = require('./getLocalIdent')
12
-
13
- const icssUtils = require('icss-utils')
14
- const localByDefault = require('postcss-modules-local-by-default')
15
- const extractImports = require('postcss-modules-extract-imports')
16
- const modulesScope = require('postcss-modules-scope')
17
- const modulesValues = require('postcss-modules-values')
18
- const valueParser = require('postcss-value-parser')
19
- const isUrlRequest = require('../utils/is-url-request')
20
- // css-loader-parser
21
-
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
- }
48
-
49
- 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) {
59
- return
60
- }
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)
66
- }
67
-
68
- importItems.push({
69
- url: url,
70
- mediaQuery: mediaQuery
71
- })
72
- rule.remove()
73
- })
74
- }
75
-
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
- })
86
- })
87
- })
88
-
89
- Object.keys(exports).forEach(function (exportName) {
90
- exports[exportName] = replaceImportsInString(exports[exportName])
91
- })
92
-
93
- function isAlias (url) {
94
- // Handle alias starting by / and root disabled
95
- return url !== options.resolve(url)
96
- }
97
-
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
- }
113
- case 'url':
114
- if (options.url && item.url.replace(/\s/g, '').length && !/^#/.test(item.url) && (isAlias(item.url) || isUrlRequest(item.url, options.root))) {
115
- // Strip quotes, they will be re-added if the module needs them
116
- item.stringType = ''
117
- delete item.innerSpacingBefore
118
- delete item.innerSpacingAfter
119
- const url = item.url
120
- item.url = '___CSS_LOADER_URL___' + urlItems.length + '___'
121
- urlItems.push({
122
- url: url
123
- })
124
- }
125
- break
126
- }
127
- }
128
-
129
- css.walkDecls(function (decl) {
130
- const values = Tokenizer.parseValues(decl.value)
131
- values.nodes.forEach(function (value) {
132
- value.nodes.forEach(processNode)
133
- })
134
- decl.value = Tokenizer.stringifyValues(values)
135
- })
136
- css.walkAtRules(function (atrule) {
137
- if (typeof atrule.params === 'string') {
138
- atrule.params = replaceImportsInString(atrule.params)
139
- }
140
- })
141
-
142
- options.importItems = importItems
143
- options.urlItems = urlItems
144
- options.exports = exports
145
- }
146
- }
147
- }
148
-
149
- module.exports = function processCss (inputSource, inputMap, options, callback) {
150
- const query = options.query
151
- const root = query.root && query.root.length > 0 ? query.root.replace(/\/$/, '') : query.root
152
- const context = query.context
153
- const localIdentName = query.localIdentName || '[hash:base64]'
154
- const localIdentRegExp = query.localIdentRegExp
155
- const forceMinimize = query.minimize
156
- const minimize = typeof forceMinimize !== 'undefined' ? !!forceMinimize : options.minimize
157
-
158
- const customGetLocalIdent = query.getLocalIdent || getLocalIdent
159
-
160
- const parserOptions = {
161
- root: root,
162
- mode: options.mode,
163
- url: query.url !== false,
164
- import: query.import !== false,
165
- resolve: options.resolve
166
- }
167
-
168
- const pipeline = postcss([
169
- modulesValues,
170
- localByDefault({
171
- mode: options.mode,
172
- rewriteUrl: function (global, url) {
173
- if (parserOptions.url) {
174
- url = url.trim()
175
-
176
- if (!url.replace(/\s/g, '').length || !isUrlRequest(url, root)) {
177
- return url
178
- }
179
- if (global) {
180
- return loaderUtils.urlToRequest(url, root)
181
- }
182
- }
183
- return url
184
- }
185
- }),
186
- extractImports(),
187
- modulesScope({
188
- generateScopedName: function generateScopedName (exportName) {
189
- return customGetLocalIdent(options.loaderContext, localIdentName, exportName, {
190
- regExp: localIdentRegExp,
191
- hashPrefix: query.hashPrefix || '',
192
- context: context
193
- })
194
- }
195
- }),
196
- parserPlugin(parserOptions)
197
- ])
198
-
199
- if (minimize) {
200
- const cssnano = require('cssnano')
201
- const minimizeOptions = assign({}, query.minimize);
202
- ['zindex', 'normalizeUrl', 'discardUnused', 'mergeIdents', 'reduceIdents', 'autoprefixer', 'svgo'].forEach(function (name) {
203
- if (typeof minimizeOptions[name] === 'undefined') {
204
- minimizeOptions[name] = false
205
- }
206
- })
207
- pipeline.use(cssnano(minimizeOptions))
208
- }
209
-
210
- pipeline.process(inputSource, {
211
- // we need a prefix to avoid path rewriting of PostCSS
212
- from: '/css-loader!' + options.from,
213
- to: options.to,
214
- map: options.sourceMap
215
- ? {
216
- prev: inputMap,
217
- sourcesContent: true,
218
- inline: false,
219
- annotation: false
220
- }
221
- : null
222
- }).then(function (result) {
223
- callback(null, {
224
- source: result.css,
225
- map: result.map && result.map.toJSON(),
226
- exports: parserOptions.exports,
227
- importItems: parserOptions.importItems,
228
- importItemRegExpG: /___CSS_LOADER_IMPORT___([0-9]+)___/g,
229
- importItemRegExp: /___CSS_LOADER_IMPORT___([0-9]+)___/,
230
- urlItems: parserOptions.urlItems,
231
- urlItemRegExpG: /___CSS_LOADER_URL___([0-9]+)___/g,
232
- urlItemRegExp: /___CSS_LOADER_URL___([0-9]+)___/
233
- })
234
- }).catch(function (err) {
235
- if (err.name === 'CssSyntaxError') {
236
- const wrappedError = new CSSLoaderError(
237
- 'Syntax Error',
238
- err.reason,
239
- err.line != null && err.column != null
240
- ? { line: err.line, column: err.column }
241
- : null,
242
- err.input.source
243
- )
244
- callback(wrappedError)
245
- } else {
246
- callback(err)
247
- }
248
- })
249
- }
250
-
251
- function formatMessage (message, loc, source) {
252
- let formatted = message
253
- if (loc) {
254
- formatted = formatted +
255
- ' (' + loc.line + ':' + loc.column + ')'
256
- }
257
- if (loc && source) {
258
- formatted = formatted +
259
- '\n\n' + formatCodeFrame(source, loc.line, loc.column) + '\n'
260
- }
261
- return formatted
262
- }
263
-
264
- function CSSLoaderError (name, message, loc, source, error) {
265
- Error.call(this)
266
- Error.captureStackTrace(this, CSSLoaderError)
267
- this.name = name
268
- this.error = error
269
- this.message = formatMessage(message, loc, source)
270
- this.message = formatMessage(message, loc, source)
271
- }
272
-
273
- CSSLoaderError.prototype = Object.create(Error.prototype)
274
- CSSLoaderError.prototype.constructor = CSSLoaderError