Skip to content

Commit

Permalink
[import-maps] Re-implement dynamic resource (#18648)
Browse files Browse the repository at this point in the history
The "sub" functionality of wptserve's "pipe" feature has previously been
identified as a candidate for removal [1]. While it can generally be
replaced with a filename-based pattern, the optional argument can only
be specified with the query-string-based approach.

The file `static-import.js` in the import-maps test suite is the only
existing usage of the optional argument. Refactor it to use a Python
handler so that a future patch may replace the remaining "pipe"-based
usages with filename-based usages.

[1] #15680
  • Loading branch information
jugglinmike committed Nov 4, 2019
1 parent 8a0958f commit 287f2dd
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
1 change: 0 additions & 1 deletion import-maps/builtin-support.tentative/static-import.js

This file was deleted.

5 changes: 5 additions & 0 deletions import-maps/builtin-support.tentative/static-import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def main(request, response):
return (
(('Content-Type', 'text/javascript'),),
'import "{}";\n'.format(request.GET.first('url'))
)
1 change: 0 additions & 1 deletion import-maps/core/static-import.js

This file was deleted.

5 changes: 5 additions & 0 deletions import-maps/core/static-import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def main(request, response):
return (
(('Content-Type', 'text/javascript'),),
'import "{}";\n'.format(request.GET.first('url'))
)
2 changes: 1 addition & 1 deletion import-maps/resources/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function testStaticImport(importMapString, importMapBaseURL, specifier, expected
const script = document.createElement("script");
script.setAttribute("type", "module");
script.setAttribute("src",
"static-import.js?pipe=sub(none)&url=" +
"static-import.py?url=" +
encodeURIComponent("${specifier}"));
script.addEventListener("load", handlers[Handler.ScriptLoadEvent]);
script.addEventListener("error", handlers[Handler.ScriptErrorEvent]);
Expand Down

0 comments on commit 287f2dd

Please sign in to comment.