-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Parser Rework: NPM Package Support, import/export tracing, Internal Structure Refactor, Playground and more #66
Merged
Conversation
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
* Adds Laravel importmap eager and lazy loading examples * Adds the vite-laravel setup * Add tests for Laravel app fixtures --------- Co-authored-by: Marco Roth <marco.roth@intergga.ch>
Also added symetrical getters for `valueNames` and `localValueNames` and two additional getters for keeping the return value of previous getter around: `valueDefinitionsMap` and `localValueDefinitionsMap` Also added `node` to all `ControllerPropertyDefinition` And added another validation to detect duplicate properties definitions if the parent already defined it
…definitions A new `allProjectControllerDefinitions` getter is introduced on `Project` to keep the old behaviour around where we exported all found, but not exported, controller definitions.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request is a big revamp of the existing parser and also adds a lot of new features. Here are the highlights:
NPM Package Support
We now fully support Stimulus controllers imported from NPM packages installed on disk. We can trace the
import
declaration to the resolved source file within the NPM package. If the import is importing a class declaration, we can fully resolve the import to the class declaration in the NPM package.Sadly the parser doesn't yet resolve controllers imported from import-mapped NPM packages.
Stimulus Parser Playground
The pull requests features a fully interactive web-based playground to interact and inspect the parse results. The playground allows users to encode the input into a sharable URL that can come in heady for bug and issue reports.
New Internal Structure and classes to represent objects
We already had:
Project
Parser
ControllerDefinition
MethodDefinition
ValueDefinition
ClassDefinition
TargetDefinition
Newly added:
SourceFile
- A representation of a (parsed) JavaScript/TypeScript source file.ImportDeclaration
- A representation of an import declaration within aSourceFile
. If a single import statement imports two constants it will be represented with twoImportDeclaration
objects. We decide betweendefault
,named
andnamespace
imports.ExportDeclaration
- A representation of an export declaration within aSourceFile
. If a single export statement exports two constants it will be represented with twoExportDeclaration
objects. We decide betweendefault
,named
andnamespace
exports.ClassDeclaration
- A representation of any class declaration within aSourceFile
. If class declaration defines a Stimulus controller it will have thecontrollerDefinition
populated.NodeModule
- The node module represents a detected NPM package. It holds aSourceFile
for each file it contains.ApplicationFile
- The file where the Stimulus application is defined/started in and exported from.ControllersIndexFile
- Responsible for detecting the registered controllers on the application.RegisteredController
- AControllerDefinition
/identifier
pair register which controllers where registered on the application with which identifier.Analysis of registered controllers on the
Stimulus
applicationThe
Project
now exposescontrollerDefinitions
andregisteredControllers
, wherecontrollerDefinitions
contain any of the controller definitions the parser found in the project andregisteredControllers
are the controllers the were actually detected to be registered on theStimulus
Application with an identifier.The
controllerDefinitions
have aguessIdentifier
property that uses a best effort strategy to come up with the most likely identifier somewhere would register this controllers as, this also includes controllers found in the installed NPM packages.The
registeredControllers
have anidentifier
property, for which we are certain the this controller was registered with this identifier, either by manually callingapplication.register(...)
or through one of the autoload plugins we support. Currently we have support for the following mechanisms:register
stimulus-loading-lazy
stimulus-loading-eager
esbuild-rails
stimulus-vite-helpers
stimulus-webpack-helpers
But we would love to implement support for other autoload mechanisms.
Test coverage
This pull requests also introduces tons of new tests to make sure we ensure we don't introduce any regressions.
Resolved Issues
Closes #29
Closes #51
Closes #52
Closes #54
Closes #61
Closes #63
Closes #64
Closes #65