-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add Dependabot * remove pragma dependency * add Global to import list * build pkg post install script * Create wild-carpets-repeat.md * update dependency list
- Loading branch information
1 parent
933d2e0
commit 4affc53
Showing
8 changed files
with
138 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"babel-plugin-filbert": patch | ||
"@filbert-js/macro": patch | ||
"@filbert-js/website": patch | ||
--- | ||
|
||
remove pragma annotation dependency |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,29 @@ | ||
const { createMacro } = require('babel-plugin-macros'); | ||
const { addNamed } = require('@babel/helper-module-imports'); | ||
|
||
const babelPlugin = require('babel-plugin-filbert'); | ||
|
||
const source = '@filbert-js/core'; | ||
const name = 'styled'; | ||
|
||
function filbertMacro({ references, babel, state }) { | ||
const program = state.file.path; | ||
|
||
const imports = {}; | ||
|
||
Object.keys(references).forEach((refName) => { | ||
const id = addNamed(program, refName, source); | ||
const id = addNamed(program, refName, source, { nameHint: refName }); | ||
|
||
imports[refName] = id.name; | ||
references[refName].forEach((referencePath) => { | ||
referencePath.node.name = id.name; | ||
}); | ||
}); | ||
|
||
const t = babel.types; | ||
|
||
const namedReferences = references[name] || []; | ||
|
||
namedReferences.forEach((referencePath) => { | ||
const path = referencePath.parentPath; | ||
const type = path.type; | ||
const node = path.node; | ||
if (type === 'MemberExpression') { | ||
const functionName = node.object.name; | ||
let elementName = node.property.name; | ||
|
||
// Support custom elements | ||
if (/[A-Z]/.test(elementName)) { | ||
elementName = elementName.replace(/[A-Z]/g, '-$&').toLowerCase(); | ||
} | ||
|
||
path.replaceWith( | ||
t.callExpression(t.identifier(functionName), [ | ||
t.stringLiteral(elementName), | ||
]), | ||
); | ||
} | ||
}); | ||
babel.traverse( | ||
program.parent, | ||
babelPlugin(babel, { imports }).visitor, | ||
undefined, | ||
state, | ||
); | ||
} | ||
module.exports = createMacro(filbertMacro); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4affc53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: