Skip to content

Commit

Permalink
refactor: move supported views array to file (#147)
Browse files Browse the repository at this point in the history
* refactor: move supported views array to file

* add "choo" module to supported views
  • Loading branch information
ungoldman authored and goto-bus-stop committed Apr 26, 2019
1 parent 98b1ead commit 09608d8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const hyperx = require('hyperx')
const SVG_TAGS = require('./svg-tags')
const BOOL_PROPS = require('./bool-props')
const DIRECT_PROPS = require('./direct-props')
const SUPPORTED_VIEWS = require('./supported-views')

const SVGNS = 'http://www.w3.org/2000/svg'
const XLINKNS = 'http://www.w3.org/1999/xlink'
Expand Down Expand Up @@ -49,7 +50,6 @@ function removeBindingImport (binding) {

module.exports = (babel) => {
const t = babel.types
const nanohtmlModuleNames = ['nanohtml', 'bel', 'yo-yo', 'choo/html', 'hui/html']

/**
* Returns an object which specifies the custom elements by which a built-in is extended.
Expand Down Expand Up @@ -347,7 +347,7 @@ module.exports = (babel) => {
}

const importFrom = firstArg.value
return nanohtmlModuleNames.indexOf(importFrom) !== -1
return SUPPORTED_VIEWS.indexOf(importFrom) !== -1
}

return {
Expand Down Expand Up @@ -410,7 +410,7 @@ module.exports = (babel) => {
*/
ImportDeclaration (path, state) {
const importFrom = path.get('source').node.value
if (nanohtmlModuleNames.indexOf(importFrom) !== -1) {
if (SUPPORTED_VIEWS.indexOf(importFrom) !== -1) {
const specifier = path.get('specifiers')[0]
if (specifier.isImportDefaultSpecifier()) {
this.nanohtmlBindings.add(path.scope.getBinding(specifier.node.local.name))
Expand Down
2 changes: 1 addition & 1 deletion lib/browserify-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ var hyperx = require('hyperx')
var acorn = require('acorn')
var path = require('path')
var SVG_TAGS = require('./svg-tags')
var SUPPORTED_VIEWS = require('./supported-views')

var SUPPORTED_VIEWS = ['nanohtml', 'bel', 'yo-yo', 'choo', 'choo/html', 'hui/html']
var DELIM = '~!@|@|@!~'
var VARNAME = 'nanohtml'
var SVGNS = 'http://www.w3.org/2000/svg'
Expand Down
8 changes: 8 additions & 0 deletions lib/supported-views.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = [
'nanohtml',
'bel',
'yo-yo',
'choo/html',
'choo', // Support choo 3.x-style require('choo').view``
'hui/html'
]

0 comments on commit 09608d8

Please sign in to comment.