@dolphinweex/weex-harmony 0.1.3 → 0.1.5
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/package.json +1 -3
- package/src/transform-loader.js +38 -14
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@dolphinweex/weex-harmony",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.5",
|
4
4
|
"description": "weex harmony adapter",
|
5
5
|
"main": "index.js",
|
6
6
|
"files": [
|
@@ -20,9 +20,7 @@
|
|
20
20
|
"vue-style-loader": "^4.1.1",
|
21
21
|
"vue-template-compiler": "^2.6.11",
|
22
22
|
"himalaya": "^1.1.0",
|
23
|
-
"babel-core": "^6.26.0",
|
24
23
|
"babel-eslint": "^10.0.2",
|
25
|
-
"babel-loader": "^7.1.1",
|
26
24
|
"babel-plugin-component": "^1.1.1",
|
27
25
|
"babel-plugin-transform-runtime": "^6.23.0",
|
28
26
|
"babel-preset-stage-0": "^6.24.1",
|
package/src/transform-loader.js
CHANGED
@@ -152,8 +152,20 @@ function generateCode(moduleResoveRet) {
|
|
152
152
|
let styleAttrs = ''
|
153
153
|
let scriptAttrs = ''
|
154
154
|
|
155
|
-
|
155
|
+
let styleStr = ''
|
156
|
+
moduleResoveRet.styles.forEach((item, i) => {
|
157
|
+
styleTemplate = ''
|
158
|
+
styleAttrs = ''
|
156
159
|
styleTemplate += item.content
|
160
|
+
|
161
|
+
Object.keys(moduleResoveRet.styles[i].attrs).forEach((item) => {
|
162
|
+
if (typeof moduleResoveRet.styles[i].attrs[item] === 'boolean') {
|
163
|
+
styleAttrs += ` ${item}`
|
164
|
+
} else {
|
165
|
+
styleAttrs += ` ${item}="${moduleResoveRet.styles[i].attrs[item]}"`
|
166
|
+
}
|
167
|
+
})
|
168
|
+
styleStr += `<style${styleAttrs}>${styleTemplate}</style>\n`
|
157
169
|
})
|
158
170
|
|
159
171
|
Object.keys(moduleResoveRet.script.attrs).forEach((item) => {
|
@@ -164,20 +176,10 @@ function generateCode(moduleResoveRet) {
|
|
164
176
|
}
|
165
177
|
})
|
166
178
|
|
167
|
-
if(moduleResoveRet.styles.length){
|
168
|
-
Object.keys(moduleResoveRet.styles[0].attrs).forEach((item) => {
|
169
|
-
if (typeof moduleResoveRet.styles[0].attrs[item] === 'boolean') {
|
170
|
-
styleAttrs += ` ${item}`
|
171
|
-
} else {
|
172
|
-
styleAttrs += ` ${item}="${moduleResoveRet.styles[0].attrs[item]}"`
|
173
|
-
}
|
174
|
-
})
|
175
|
-
}
|
176
|
-
|
177
179
|
const template = `
|
178
|
-
<template>${moduleResoveRet.template.content}</template>
|
179
|
-
<script${scriptAttrs}>${moduleResoveRet.script.content}</script>
|
180
|
-
|
180
|
+
<template>${moduleResoveRet.template.content}</template>
|
181
|
+
<script${scriptAttrs}>${moduleResoveRet.script.content}</script>
|
182
|
+
${styleStr}
|
181
183
|
`
|
182
184
|
return template
|
183
185
|
}
|
@@ -220,6 +222,28 @@ module.exports = function (source) {
|
|
220
222
|
path.unshiftContainer('body', buildImportDeclaration(componentName))
|
221
223
|
})
|
222
224
|
},
|
225
|
+
AssignmentExpression(path) {
|
226
|
+
const left = path.node.left;
|
227
|
+
if (
|
228
|
+
left.type === 'MemberExpression' &&
|
229
|
+
left.object.name === 'module' &&
|
230
|
+
left.property.name === 'exports'
|
231
|
+
) {
|
232
|
+
if (componentSet.size !== 0) {
|
233
|
+
if (t.isObjectExpression(path.node.right)) {
|
234
|
+
const properties = path.node.right.properties
|
235
|
+
const result = properties.find(item => item.key.name == 'components')
|
236
|
+
if (result) {
|
237
|
+
addComponentsProperty(result)
|
238
|
+
} else {
|
239
|
+
const componentsAst = t.objectProperty(t.identifier('components'), t.objectExpression([]))
|
240
|
+
properties.push(componentsAst)
|
241
|
+
addComponentsProperty(componentsAst)
|
242
|
+
}
|
243
|
+
}
|
244
|
+
}
|
245
|
+
}
|
246
|
+
},
|
223
247
|
ExportDefaultDeclaration(path) {
|
224
248
|
if (componentSet.size !== 0) {
|
225
249
|
if (t.isObjectExpression(path.node.declaration)) {
|