-
-
Notifications
You must be signed in to change notification settings - Fork 603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ast(cli): Recursively parse AST #341
Changes from 3 commits
e82c7eb
c388042
a573ff8
15edbb2
c2ef49f
f961419
5b4b623
b8f4979
af8393d
c64ed99
ea02412
6ff4248
9892028
2b1f1d5
0ce8138
3d7fba8
9e7e2b5
ef9327a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"webpack-addons-demo": { | ||
"configuration": { | ||
"dev": { | ||
"webpackOptions": { | ||
"entry": "ok", | ||
"output": { | ||
"filename": "'[name].js'" | ||
}, | ||
"context": "path.join(__dirname, \"src\")", | ||
"plugins": [ | ||
"new webpack.optimize.CommonsChunkPlugin({name:'k',filename:'k-[hash].min.js'})" | ||
] | ||
}, | ||
"topScope": [ | ||
"const path = require(\"path\")", | ||
"const webpack = require(\"webpack\")" | ||
], | ||
"configName": "pengwings" | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"use strict"; | ||
|
||
const utils = require("../utils/ast-utils"); | ||
|
||
module.exports = function astTransform(j, ast, value, action, key) { | ||
const node = utils.findRootNodesByName(j, ast, key); | ||
if (node.size() !== 0) { | ||
// push to existing key | ||
} else { | ||
// get module.exports prop | ||
const root = ast | ||
.find(j.ObjectExpression) | ||
.filter(p => { | ||
return ( | ||
utils.safeTraverse(p, [ | ||
"parentPath", | ||
"value", | ||
"left", | ||
"object", | ||
"name" | ||
]) === "module" && | ||
utils.safeTraverse(p, [ | ||
"parentPath", | ||
"value", | ||
"left", | ||
"property", | ||
"name" | ||
]) === "exports" | ||
); | ||
}) | ||
.filter(p => p.value.properties); | ||
|
||
return root.forEach(p => { | ||
utils.addProperty(j, p, key, value); | ||
}); | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
const yeoman = require("yeoman-environment"); | ||
const PluginGenerator = require("../generators/plugin-generator").PluginGenerator; | ||
const PluginGenerator = require("../generators/plugin-generator") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be destructured :) const { PluginGenerator } = require("../generators/plugin-generator") There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Im not done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah and in the meantime we give feedback while you develop :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotcha, just don't want you to do extra work 🙌🤙 |
||
.PluginGenerator; | ||
|
||
/** | ||
* Runs a yeoman generator to create a new webpack plugin project | ||
|
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.
Ups, forgot this!