-
Notifications
You must be signed in to change notification settings - Fork 133
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
Plugin system #152
Plugin system #152
Conversation
…to source) - Tests now restore original operation after running to avoid polluting other tests (since they modify static values versus instance values) - filterProps test util now handles bool and null properly
…ependency injection - Added plugin registration to JSEP. Plugins have a `name` and an `init` function that is called on registration with JSEP. - Updated Object + Ternary plugins. Ternary plugin is registered by default - Updated rollup to build each plugin as a separate output (all formats). Also delete dist folder before building. - don't pollute the JSEP namespace from plugins. Use local constants instead.
Co-authored-by: Lea Verou <lea@verou.me>
(single object arg, single array of objects arg, multiple objects arg)
…to readme - gobbleExpression and gobbleToken need to stop running hooks once a node is found, similar to how jsep checks when calling each successive gobble method now. This saves each hook from having to check for `env.node` (and potentially leading to future errors with 2 hooks parsing 2 sequential expressions as just the last node). Added unit tests.
…between plugins and tests
- works in objects { ...a }, arrays [...a], function args fn(...a) - NOTE: does not prevent `a ? ...b : ...c` or `...123`
() => x x => x (a, b) => x Treats '=>' as a binary operator, but replaces the binary expression with the correct node type afterward
- supports // and /* */ style - throws an error on missing closing */
a = 2 a *= 2 Treats each assignment operator as a binary operator, but replaces the binary expression with the 'AssignmentExpression' node type afterward
Update plugin system to use registration
Object plugin
Comment Plugin
'new' plugin
Template Literal plugin
Spread Operator Plugin
@LeaVerou - I merged the approved PRs into this branch because I was thinking it would be better to ensure everything is working together and that we're happy with the API, documentation, etc. before merging all of it into master and releasing a new version. Buf if you would prefer to merge straight into main that's fine with me too 🤷🏻♀️ |
I'm not used to the workflow of releasing a new version every time a PR is merged, but I'm not opposed to it either. 🤷🏼♀️ |
RegExp plugin:
Arrow Function plugin
- rollup should use src/index.js so ternary plugin is included by default - fix type defs
# Conflicts: # README.md # rollup.config.js # test/tests.js
I typically don't either ... but I thought for a significant change like this it might make more sense. Especially if we're updating the readme docs but haven't yet published to npm 🤷🏻♀️ At any rate, I think it's nearly ready. I just updated the .npmignore file after I noticed what was included ( One issue I noticed, when trying to use the build in a typescript project, is that the plugins themselves don't have a type definition:
I could fix it by adding types to the tsd.ts file:
Or do you have a better suggestion? (I'd hate to do nothing and force 'allow implicit any', or have to manually declare the module) |
Can we have separate typings per module, included in its own directory? I'd like them to be as self-contained as possible. |
assignment/update Plugin
Maybe we should make the plugins more like a mono repo then? So that each plugin is individually published to npm (i.e. |
…n folder with its own package.json, rollup, etc. This keeps them more independent of jsep and allows for separate versioning
- remove .gitignore (root file works) - remove rollup.config.js (and use a single file at the root) Add plugin-specific types Fix New plugin adding 'new' to a MemberExpression instead of the CallExpression
Plugin mono repo
@LeaVerou and @EricSmekens - I think this should have all of the PRs and changes that were already individually reviewed and approved. Do you want one more review of the branch before merging all to main? With the separate packages per plugin, should the github actions be updated? |
Approval on my side on merging this all to main. Thank you for all your time and work on this! I think the actions should be updated, but I'm fine with that in a seperate pr. |
I think each plugin package could be manually published ( |
Approval on my side too. We can always iterate with other PRs. |
FYI - I started working on updating expression-eval to support the new node types and have been confirming that it can evaluate the nodes and use the updated jsep and packages. Merging! :-) |
This is exciting, I'm looking forward to using the |
Staging area before releasing all plugins to main