-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
I2I: src/core
directory with no runtime dependencies
#32693
Comments
Related to #27408 |
Bikeshed: In particular want to avoid |
Absolutely agree |
And another food for thought: are we going to dupe |
+1 to simplifying |
I think we should just go ahead and break the dependency with |
src/shared
directory with no runtime dependenciessrc/core
directory with no runtime dependencies
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
Overview
The main
amphtml/src
directory holds over 100 JS files (almost 300 if you count subdirectory contents). Some of these files are isolated utilities like date parsing, string manipulations, etc. Others seem like small utilities, but may actually depend on large chunks of the runtime and a whole web of dependenciesExample of issue: At the time of this writing,
src/preact/base-element
importsdevAssert
, which in turn initializes logging constructors, two different loggers, binds a global error handler, pulls in the AMP config and runtime version, andgetMode
helpers reading from AMP global variables. Suddenly, because of this one import, every Bento component depends directly on all of this AMP boilerplate. This is an extremely easy oversight for any developer.Edit: There are other dependencies of
src/preact/base-element
that have transitive dependencies on assertions/logging; it is not just this importAMP components can rely on and use any of these files. Preact/Bento components cannot, or they'll pull in whole chunks of the AMP dependency tree. As more Bento components are written, more shared helpers are needed, and it becomes harder to pull only "pure" helpers.
I propose creating a dedicated directory (ex.
amphtml/src/shared
) for these files. New shared helpers would go here. Existing helpers could be moved gradually as they are needed. ESLint rules could be added to block importing from non-shared modules so devs get a warning at dev-time rather than by seeing the bundle size after compilation.Suggested Approach
src/shared/
directory./*
and remain sharedsrc/preact
can import fromsrc/shared
orsrc/preact
without pulling in AMP dependencies./shared
, including runtime helpersshared
directory requiring explicit add-in, instead of "opt-out"runtime
directoryshared
; only move helpers as they are usedsrc/
filesTL;DR - Directory of helpers that can be included with Preact/Bento packages and have nothing to do with AMP
Steps
/src/shared
directory/src/shared
and/src/preact
/src/shared
AlternativesConsidered
pureFooBar
helpers/cc @ampproject/wg-bento @ampproject/wg-performance
The text was updated successfully, but these errors were encountered: