You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PRs 1-5 should only take a few minutes to review each. They have been split out from the main PR to preserve your sanity.
PR 6 contains the meat of the implementation.
Polymer Modulizer was originally built to be run on a single repo at a time, with dependencies installed within that repo. The Modulizer would follow a packages dependency imports, convert those files, and then create new JS imports that pointed to the expected location of the converted dependencies on NPM.
When "Workspace mode" (the ability to convert multiple repos at once) was added, dependencies were installed as siblings of the main repos under conversion. This allowed a more efficient workspace installation (dependencies shared across repos) and a more efficient analysis (less files to analyze, entire workspace could be analyzed at once).
Unfortunately, the original code had been hardcoded to specifically expect dependencies as bower_components/ children and not siblings directories. Workspace mode was added without updating this expectation. Instead, entire workspaces were converted as if they were a single package, with every file being local to one-another.
This work-around allowed us to quickly publish alpha versions of most polymer elements, but has gone on to cause several bugs (specifically around dependency loading and import formatting) and block many new features (smarter import formatting, supporting names vs. paths, etc).
Remove all hardcoded, package-layout-specific URL logic from DocumentConverter, conversion runners, etc.
Move all layout URL logic & responsibilities to a single place, if possible.
Design Overview
This design refactors the conversion coordinating "middle" layer of the Modulizer. It avoids any major changes to the higher-level CLI interface or the lower-level document specific conversion logic.
All the hardcoded expectations for how Analyzer URLs are handled, processed, understood, loaded, and formatted into imports have been pulled into a generic UrlHandlerInterface
A PackageUrlHandler is used for single package layouts, where all dependencies are located
within the package directory.
A WorkspaceUrlHandler is used for workspace layouts, where all dependencies are located as siblings of each other.
By understanding the package->dependency relationship, UrlHandlers contain all the layout-specific logic needed for proper document conversion.
All other pieces of Polymer Modulizer can be layout-agnostic by delegating to a specific UrlHandler.
By leveraging a layout-specific UrlHandlerInterface implementation, ProjectConverter can be written without the need for extension.
The conversion logic previously split across BaseConverter, AnalysisConverter, and WorkspaceConverter has all been consolidated into a single ProjectConverter class.
The text was updated successfully, but these errors were encountered:
FredKSchott
changed the title
Refactor Project Converter to Add URL Handling
Refactor Project Converter to Fix URL Handling
Nov 7, 2017
FredKSchott
changed the title
Refactor Project Converter to Fix URL Handling
Refactor ProjectConverter to Fix URL Handling
Nov 7, 2017
FredKSchott
changed the title
Refactor ProjectConverter to Fix URL Handling
[Megathread] Refactor ProjectConverter to Fix URL Handling
Nov 7, 2017
Resolves #202 #203 #184 (#200 maybe, needs to be confirmed)
Implements #213
The PRs (Reviewers, Start Here)
PRs 1-5 should only take a few minutes to review each. They have been split out from the main PR to preserve your sanity.
PR 6 contains the meat of the implementation.
outputs
keying to prevent cache missing, duplicatesurl-converter.ts
logic into theurls/
subdirectoryConversionSettings
fromConversionMetadata
lookupDependencyMapping()
ProjectConverter
You can see/compare/check out the final branch here: workspace-converter-refactor-8
Background
Polymer Modulizer was originally built to be run on a single repo at a time, with dependencies installed within that repo. The Modulizer would follow a packages dependency imports, convert those files, and then create new JS imports that pointed to the expected location of the converted dependencies on NPM.
When "Workspace mode" (the ability to convert multiple repos at once) was added, dependencies were installed as siblings of the main repos under conversion. This allowed a more efficient workspace installation (dependencies shared across repos) and a more efficient analysis (less files to analyze, entire workspace could be analyzed at once).
Unfortunately, the original code had been hardcoded to specifically expect dependencies as
bower_components/
children and not siblings directories. Workspace mode was added without updating this expectation. Instead, entire workspaces were converted as if they were a single package, with every file being local to one-another.This work-around allowed us to quickly publish alpha versions of most polymer elements, but has gone on to cause several bugs (specifically around dependency loading and import formatting) and block many new features (smarter import formatting, supporting names vs. paths, etc).
Goals
Design Overview
This design refactors the conversion coordinating "middle" layer of the Modulizer. It avoids any major changes to the higher-level CLI interface or the lower-level document specific conversion logic.
ConversionSettings
ConversionMetadata
have been pulled out and refactored intoConversionSettings
.ConversionSettings
stores static, readonly options for each conversion. For example: which namespaces to include, which files to exclude, etc.UrlHandler
UrlHandlerInterface
PackageUrlHandler
is used for single package layouts, where all dependencies are locatedwithin the package directory.
WorkspaceUrlHandler
is used for workspace layouts, where all dependencies are located as siblings of each other.ProjectConverter
UrlHandlerInterface
implementation, ProjectConverter can be written without the need for extension.BaseConverter
,AnalysisConverter
, andWorkspaceConverter
has all been consolidated into a singleProjectConverter
class.The text was updated successfully, but these errors were encountered: