Comparing version 1.6.1 to 1.7.0
const { addHook } = require('pirates'); | ||
let transpileJsx = require('@a-la/jsx'); if (transpileJsx && transpileJsx.__esModule) transpileJsx = transpileJsx.default; | ||
const { syncTransform } = require('./lib/transform'); | ||
let added | ||
/** Enable transpilation of files on-the file as a require hook. */ | ||
const alamode = () => { | ||
const alamode = ({ | ||
pragma = 'const { h } = require("preact");', | ||
} = {}) => { | ||
if (added) return | ||
added = true | ||
addHook( | ||
@@ -13,4 +19,13 @@ (code, filename) => { | ||
) | ||
addHook( | ||
(code, filename) => { | ||
const r = syncTransform(code, filename, true) | ||
const res = transpileJsx(r, { quoteProps: 1 }) | ||
const hc = `${pragma}${res}` | ||
return hc | ||
}, | ||
{ exts: ['.jsx'] } | ||
) | ||
} | ||
module.exports=alamode |
@@ -103,4 +103,5 @@ const { Replaceable } = require('restream'); | ||
*/ | ||
const syncTransform = (source, filename, advanced) => { | ||
const replaced = transformString(source, advanced) | ||
const syncTransform = (source, filename, noMap) => { | ||
const replaced = transformString(source) | ||
if (noMap) return replaced | ||
const file = basename(filename) | ||
@@ -107,0 +108,0 @@ const sourceRoot = dirname(filename) |
@@ -0,1 +1,7 @@ | ||
## 24 January 2019 | ||
### 1.7.0 | ||
- [feature] Add `JSX` hook. | ||
## 9 December 2018 | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "alamode", | ||
"version": "1.6.1", | ||
"version": "1.7.0", | ||
"description": "A Regex-based Transpiler Of Source Code To Allow Writing Import And Export Statements.", | ||
@@ -19,3 +19,3 @@ "main": "build", | ||
"build": "yarn-s b doc", | ||
"b": "yarn dev src -o build2 -i bin/index.js -s", | ||
"b": "yarn dev src -o build -i bin/index.js -s", | ||
"bf": "yarn dev test/fixture/src -o build2" | ||
@@ -65,2 +65,3 @@ }, | ||
"eslint-config-artdeco": "1.0.1", | ||
"preact": "8.4.2", | ||
"snapshot-context": "2.0.4", | ||
@@ -75,2 +76,3 @@ "spawncommand": "2.1.0", | ||
"@a-la/import": "1.7.0", | ||
"@a-la/jsx": "1.2.2", | ||
"@a-la/markers": "1.0.3", | ||
@@ -77,0 +79,0 @@ "@wrote/ensure-path": "1.0.3", |
45866
395
13
10
+ Added@a-la/jsx@1.2.2
+ Added@a-la/detect-jsx@1.0.1(transitive)
+ Added@a-la/jsx@1.2.2(transitive)