alloy-compiler
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -6,2 +6,13 @@ # Change Log | ||
## [0.2.2](https://github.com/appcelerator/alloy-devkit/compare/v0.2.1...v0.2.2) (2020-05-18) | ||
### Bug Fixes | ||
* **compiler:** correct looping of style keys ([#61](https://github.com/appcelerator/alloy-devkit/issues/61)) ([e76394b](https://github.com/appcelerator/alloy-devkit/commit/e76394b70152b0e3dd8c6678d84d26c08b04b420)) | ||
## [0.2.1](https://github.com/appcelerator/alloy-devkit/compare/v0.2.0...v0.2.1) (2020-03-04) | ||
@@ -8,0 +19,0 @@ |
@@ -27,6 +27,3 @@ const fs = require('fs-extra'); | ||
// make sure the alloy build folder exists | ||
if (!fs.existsSync(dir)) { | ||
fs.mkdirpSync(dir); | ||
chmodr.sync(dir, 0o755); | ||
} | ||
fs.ensureDirSync(dir); | ||
@@ -33,0 +30,0 @@ // load it up |
@@ -1,3 +0,4 @@ | ||
const { tiapp } = require('alloy-utils'); | ||
const fs = require('fs'); | ||
const babel = require('@babel/core'); | ||
const { constants: CONST, tiapp, utils: U } = require('alloy-utils'); | ||
const fs = require('fs-extra'); | ||
const path = require('path'); | ||
@@ -7,2 +8,3 @@ | ||
const CompilationMeta = require('./meta'); | ||
const { configureBabelPlugins } = require('./utils'); | ||
const styler = require('../styler'); | ||
@@ -46,4 +48,5 @@ | ||
if (!options.fs) { | ||
options.fs = fs; | ||
options.fs = require('fs'); | ||
} | ||
const compilationMeta = new CompilationMeta(options); | ||
@@ -59,5 +62,8 @@ this.compilationMeta = compilationMeta; | ||
// make sure `build/alloy` exists | ||
fs.ensureDirSync(path.join(compileConfig.dir.project, CONST.DIR.BUILD)); | ||
// Load global styles | ||
styler.setPlatform(compileConfig.alloyConfig.platform); | ||
const theme = options.compileConfig.theme; | ||
const theme = compileConfig.theme; | ||
styler.loadGlobalStyles(compileConfig.dir.home, theme ? { theme } : {}); | ||
@@ -68,3 +74,20 @@ } | ||
const compiler = this.factory.createCompiler('component'); | ||
return compiler.compile(options); | ||
const result = compiler.compile(options); | ||
if (this.compilationMeta.isWebpack) { | ||
return result; | ||
} | ||
const babelOptions = { | ||
babelrc: false, | ||
retainLines: true, | ||
plugins: configureBabelPlugins(this.config), | ||
inputSourceMap: result.map | ||
}; | ||
try { | ||
result.code = babel.transformSync(result.code, babelOptions).code; | ||
} catch (e) { | ||
U.die('Error transforming JS file', e); | ||
} | ||
return result; | ||
} | ||
@@ -71,0 +94,0 @@ |
@@ -37,3 +37,3 @@ const { utils: U } = require('alloy-utils'); | ||
// create a temporary style object, sans style key | ||
Object.keys(s, k => { | ||
for (const k of Object.keys(s)) { | ||
const v = s[k]; | ||
@@ -44,3 +44,3 @@ if (k === 'queries') { | ||
// optimize style conditionals for runtime | ||
Object.keys(v, queryKey => { | ||
for (const queryKey of Object.keys(v)) { | ||
const query = v[queryKey]; | ||
@@ -56,3 +56,3 @@ if (queryKey === 'platform') { | ||
} | ||
}); | ||
} | ||
@@ -68,3 +68,3 @@ // add the queries object, if not empty | ||
} | ||
}); | ||
} | ||
@@ -71,0 +71,0 @@ // Create a full processed style string by inserting the processed style |
@@ -7,5 +7,4 @@ const { logger } = require('alloy-utils'); | ||
const sourceMapper = require('./sourceMapper'); | ||
const StandaloneCompiler = require('./compilers/standalone'); | ||
const AlloyCompiler = require('./compilers/alloy'); | ||
const { configureBabelPlugins } = require('./compilers/utils'); | ||
const WebpackCompiler = require('./compilers/webpack'); | ||
@@ -68,7 +67,3 @@ /** @typedef {import("./compilers/alloy")} AlloyCompiler */ | ||
}; | ||
if (options.webpack) { | ||
return new WebpackCompiler(mergedOptions); | ||
} else { | ||
return new StandaloneCompiler(mergedOptions); | ||
} | ||
return new AlloyCompiler(mergedOptions); | ||
} | ||
@@ -75,0 +70,0 @@ |
{ | ||
"name": "alloy-compiler", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Compiler for Alloy components", | ||
@@ -22,5 +22,5 @@ "main": "lib/index.js", | ||
"@babel/types": "^7.8.3", | ||
"alloy-utils": "^0.2.0", | ||
"alloy-utils": "^0.2.2", | ||
"chmodr": "^1.2.0", | ||
"fs-extra": "^8.1.0", | ||
"fs-extra": "^9.0.0", | ||
"jsonlint": "^1.6.3", | ||
@@ -30,3 +30,3 @@ "lodash": "^4.17.15", | ||
"walk-sync": "^2.0.2", | ||
"xmldom": "^0.2.1" | ||
"xmldom": "^0.3.0" | ||
}, | ||
@@ -36,3 +36,3 @@ "engines": { | ||
}, | ||
"gitHead": "08c32c6658845f84f9c487a2886dcb8949931026" | ||
"gitHead": "f8a8138410c6a9f3f3963cec4a8984313700013e" | ||
} |
@@ -16,5 +16,5 @@ // eslint-disable: quotes | ||
expect(code).toMatchInlineSnapshot( | ||
'"module.exports = [{\\"style\\":{color:\\"#000\\",font:{fontSize:\\"18dp\\",fontWeight:\\"bold\\",},height:Ti.UI.SIZE,width:Ti.UI.SIZE,}},{\\"style\\":{backgroundColor:\\"#fff\\",fullscreen:false,exitOnClose:true,}}];"' | ||
'"module.exports = [{\\"isApi\\":true,\\"priority\\":1000.0002,\\"key\\":\\"Label\\",\\"style\\":{color:\\"#000\\",font:{fontSize:\\"18dp\\",fontWeight:\\"bold\\",},height:Ti.UI.SIZE,width:Ti.UI.SIZE,}},{\\"isId\\":true,\\"priority\\":100000.0001,\\"key\\":\\"index\\",\\"style\\":{backgroundColor:\\"#fff\\",fullscreen:false,exitOnClose:true,}}];"' | ||
); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
917488
269
23645
17
+ Addedxmldom@0.3.0(transitive)
- Removedfs-extra@8.1.0(transitive)
- Removedjsonfile@4.0.0(transitive)
- Removeduniversalify@0.1.2(transitive)
- Removedxmldom@0.2.1(transitive)
Updatedalloy-utils@^0.2.2
Updatedfs-extra@^9.0.0
Updatedxmldom@^0.3.0