-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Interactivity API: Create @wordpress/interactivity-router module
#57924
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
Changes from 47 commits
270aaa0
09972e6
926da69
7f2f6c3
63fa0ef
5019c6e
7819728
9308769
13be90d
e90ddfc
4643f4b
07a53b6
d6b0a4e
fc423df
77bd06a
b3b3ebb
e38ff22
227aa86
adf8203
144c15c
f3a01ee
6d245b3
82a9d4a
cbf4d3e
dd7131e
2e5d7e7
8b517b8
44d2a37
ffdbdc9
0bf64e3
5c1554f
93a7ea6
94dfd8c
f752a94
5d55caa
7999837
7b9e112
d09960e
9916bea
1e6b1c5
3e50a84
e551609
e1bf002
19185a3
4e9d82a
f42d597
f7596c2
337d22a
4dcfe20
2534189
87e162d
1aaf239
c15686c
d196e04
980ad9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,9 +59,11 @@ function defaultRequestToExternal( request ) { | |
| /** | ||
| * Default request to external module transformation | ||
| * | ||
| * Currently only @wordpress/interactivity | ||
| * Currently only @wordpress/interactivity and `@wordpress/interactivity-router` | ||
| * are supported. | ||
| * | ||
| * Do not use the boolean shorthand here, it's only handled for the `requestToExternalModule` option. | ||
| * Do not use the boolean shorthand here, it's only handled for the | ||
| * `requestToExternalModule` option. | ||
| * | ||
| * @param {string} request Module request (the module name in `import from`) to be transformed | ||
| * @return {string|Error|undefined} The resulting external definition. | ||
|
|
@@ -71,13 +73,19 @@ function defaultRequestToExternal( request ) { | |
| */ | ||
| function defaultRequestToExternalModule( request ) { | ||
| if ( request === '@wordpress/interactivity' ) { | ||
| // This is a special case. Interactivity does not support dynamic imports at this | ||
| // time. We add the external "module" type to indicate that webpack should | ||
| // externalize this as a module (instead of our default `import()` external type) | ||
| // which forces @wordpress/interactivity imports to be hoisted to static imports. | ||
| // This is a special case. Interactivity does not support dynamic imports at | ||
| // this time. We add the external "module" type to indicate that webpack | ||
| // should externalize this as a module (instead of our default `import()` | ||
| // external type) which forces @wordpress/interactivity imports to be | ||
| // hoisted to static imports. | ||
| return `module ${ request }`; | ||
| } | ||
|
|
||
| if ( request === '@wordpress/interactivity/router' ) { | ||
| // Assumes this is usually giong to be used as a dynamic import. | ||
| return `import ${ request }`; | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the kind of change that I'd like us to improve as part of adding these new modules, we should be adding hacks like this when we create new packages/modules. Instead we should have everything taken care of automatically. How can we do that here?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally, all the WordPress packages should be available as modules. Once that's done, we can update this to do something similar to what's done for scripts and make any module that starts with |
||
|
|
||
| const isWordPressScript = Boolean( defaultRequestToExternal( request ) ); | ||
|
|
||
| if ( isWordPressScript ) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.