-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Interactivity API: Add build configuration for a standalone package #61681
base: trunk
Are you sure you want to change the base?
Conversation
Size Change: -140 B (-0.01%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
I'll try to give this a proper review at some point, but honestly I'm swamped right now. A quick comment is that I'd stay away from language like "CDN" which is more about how things are served. Instead, I'd talk about "standalone" which I think better indicates the goal here - to have a single file that includes everything necessary and removes the need to bundle/compile. |
That's a very good point, I've updated it. Naming is hard 🙂 |
Just a note that in case we go ahead with this, we should apply the similar changes to the |
What?
Configure webpack in the Gutenberg repo so that a minified and bundled version of the Interactivity API is also available inside of the built
@wordpress/interactivity
npm package.Why?
A few people asked to use Interactivity API without WordPress and without a build system. they would like to be able to import the package from a CDN and "just use" the Interactivity API.
With this configuration in place, we could then submit
@wordpress/interactivity
to cdn.js and have it always pull the latest versionIt is a very common pattern among JS libraries to provide a standalone build. e.g.
petite-vue
andalpine.js
both provide it. We should follow suit. It's not a very important feature in and of itself but having it contributes to the perception that the Interactivity API is easy to use and easy to get started with.How?
Adding a new webpack config and a
build
script to thepackage.json
of@wordpress/interactivity
. This build script is then run bylerna
before the packages are published (see the"prebuild:packages"
in thepackage.json
at the root of the repo).Testing Instructions
npm run build:packages
and make sure that the Interactivity API buildsbuild-cdn
index-standalone.min.js
file and on a page that uses the interactivity API and make sure that it works.packages/interactivity/build-cdn
folder is ignored by the editor andgit
.