Skip to content

Commit

Permalink
Merge pull request #1240 from didi/fix-wxss-es6
Browse files Browse the repository at this point in the history
fix:修复wxss中的高级语法问题
  • Loading branch information
hiyuki authored Jul 11, 2023
2 parents f7d1fc9 + 3d06518 commit 32cd02f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
16 changes: 8 additions & 8 deletions packages/webpack-plugin/lib/wxss/runtime/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
module.exports = (cssWithMappingToString) => {
module.exports = function (cssWithMappingToString) {
const list = []

// return the list of modules as css string
list.toString = function toString () {
return this.map((item) => {
let content = ''
return this.map(function (item) {
var content = ''

const needLayer = typeof item[5] !== 'undefined'
var needLayer = typeof item[5] !== 'undefined'

if (item[4]) {
content += `@supports (${item[4]}) {`
Expand Down Expand Up @@ -48,20 +48,20 @@ module.exports = (cssWithMappingToString) => {
modules = [[null, modules, undefined]]
}

const alreadyImportedModules = {}
var alreadyImportedModules = {}

if (dedupe) {
for (let k = 0; k < this.length; k++) {
const id = this[k][0]
var id = this[k][0]

if (id != null) {
alreadyImportedModules[id] = true
}
}
}

for (let k = 0; k < modules.length; k++) {
const item = [].concat(modules[k])
for (var k = 0; k < modules.length; k++) {
var item = [].concat(modules[k])

if (dedupe && alreadyImportedModules[item[0]]) {
continue
Expand Down
4 changes: 3 additions & 1 deletion packages/webpack-plugin/lib/wxss/runtime/noSourceMaps.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
module.exports = (i) => i[1]
module.exports = function (i) {
return i[1]
}
14 changes: 7 additions & 7 deletions packages/webpack-plugin/lib/wxss/runtime/sourceMaps.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
module.exports = (item) => {
const content = item[1]
const cssMapping = item[3]
module.exports = function (item) {
var content = item[1]
var cssMapping = item[3]

if (!cssMapping) {
return content
}

if (typeof btoa === 'function') {
// eslint-disable-next-line no-undef
const base64 = btoa(
var base64 = btoa(
unescape(encodeURIComponent(JSON.stringify(cssMapping)))
)
const data = `sourceMappingURL=data:application/json;charset=utf-8;base64,${base64}`
const sourceMapping = `/*# ${data} */`
var data = `sourceMappingURL=data:application/json;charset=utf-8;base64,${base64}`
var sourceMapping = `/*# ${data} */`

const sourceURLs = cssMapping.sources.map(
var sourceURLs = cssMapping.sources.map(
(source) => `/*# sourceURL=${cssMapping.sourceRoot || ''}${source} */`
)

Expand Down

0 comments on commit 32cd02f

Please sign in to comment.