Support the /+esm endpoint on jsDelivr packages
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- csharp, javascript, rollup
- Lĩnh vực
- developer-experience, tooling
Hướng nghiên cứu
No files or tests are named. Start by locating LibMan's provider parsing and jsDelivr download handling, then review how library and file paths are resolved. Done means an agreed /+esm form can fetch package and individual-file ESM endpoints with coverage for the supported syntax.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Is your feature request related to a problem? Please describe.
Some libraries available through jsDelivr have no default JS file specified by the package author. Libraries packaged for NPM are often meant to be included as CJS modules, with the expectation that the developer will use a tool like webpack or Rollup.js to prepare the code to run client-side. On jsDelivr packages sometimes have this disclaimer under the "install" code snippet:
No default JS file set by the package author so the URL is guessed. You can always browse all package files to use another one.
Luckily jsDelivr provides a more reliable option - fetching the library as an ES module, as illustrated in this example:
<script type="module">
import coreJs from 'https://cdn.jsdelivr.net/npm/core-js@3.45.0/+esm'
</script>
jsDelivr uses Rollup.js to generate the ESM version of the package and exposes the result when it sees /+esm appended to the URL. This is a very helpful feature provided by the CDN, but as far as I can tell there is currently no way to leverage this feature with LibMan.
Describe the solution you'd like
It would be a nice convenience if there was some way to tell LibMan to fetch pre-bundled libraries from jsDelivr. I think the simplest syntax for this would be:
{
"provider": "jsdelivr/esm",
"library": "core-js@3.45.0",
"destination": "wwwroot/lib/core-js/index.mjs"
}
The file name, [library name]/index.mjs, could be inferred, though I believe that is a separate issue.
Describe alternatives you've considered
I did try "tricking" LibMan into fetching a generated ESM for me with something like this:
{
"provider": "jsdelivr",
"library": "core-js@3.45.0",
"files": [ "/+esm" ]
}
Of course, that doesn't work because there is no literal "/+esm" file in this package. A more sensible and straightforward alternative syntax might be:
{
"provider": "jsdelivr",
"library": "core-js@3.45.0/+esm"
}
Additional context
I've found a few examples, like parse and locutus, where the /+esm endpoint is the only install option shown on the download page.
Locutus is an odd example, because the package contains a very large collection of submodules. I've found that jsDelivr supports a form of tree shaking by allowing /+esm to be appended to individual files in the library:
<script type="module">
import pcre from 'https://cdn.jsdelivr.net/npm/locutus@2.0.32/php/pcre/+esm'
import sprintf from 'https://cdn.jsdelivr.net/npm/locutus@2.0.32/php/strings/sprintf.js/+esm'
</script>
LibMan might be able to take advantage of this feature as well:
{
"provider": "jsdelivr/esm",
"library": "locutus@2.0.32",
"destination": "wwwroot/lib/locutus",
"files": [
"/php/pcre/index.js",
"/php/strings/sprintf.js"
]
}
- Ngôn ngữ chính
- C#
- Star
- 486
- Fork
- 91
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aspnet/LibraryManager
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
aspnet/LibraryManager#824 · 1 bình luận · 3 reaction ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
aspnet/LibraryManager#804 · 2 reaction ·
-
Changelog for 3.0.114 Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 48/100
aspnet/LibraryManager#829 · 1 bình luận · 3 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
aspnet/LibraryManager#820 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
aspnet/LibraryManager#808 · 5 bình luận ·
Tất cả issue của aspnet/LibraryManager
Issue tương tự
-
CS0162 "Unreachable code detected" warning from a MSBuildTemp .tmp file in every game project Đang mởbug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
Type: enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
apache/arrow-adbc#4809 ·
-
type/automation type/tech-debt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
microsoft/vscode-azurefunctions#5197 · 1 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
microsoft/microsoft-ui-reactor#1274 ·