Skip to content
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

Add sourcemap references to minified js files #13

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Package: jquerylib
Title: Obtain 'jQuery' as an HTML Dependency Object
Version: 0.1.4
Version: 0.1.4.9000
Authors@R: c(
person("Carson", "Sievert", role = c("aut", "cre"), email = "carson@rstudio.com", comment = c(ORCID = "0000-0002-4958-2844")),
person("Joe", "Cheng", role = "aut", email = "joe@rstudio.com"),
person(family = "RStudio", role = "cph"),
person(family = "RStudio", role = c("cph", "fnd")),
person(family = "jQuery Foundation", role = "cph",
comment = "jQuery library and jQuery UI library"),
person(family = "jQuery contributors", role = c("ctb", "cph"),
Expand All @@ -16,6 +16,6 @@ License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
Config/testthat/edition: 3
RoxygenNote: 7.1.2
RoxygenNote: 7.2.1
Imports: htmltools
Suggests: testthat
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# jquerylib (development version)

* Add sourcemap references to minified js files (#13)

# jquerylib 0.1.4

* `jquery_core(3)` now returns 3.6.0 instead of 3.5.1.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ stable version of jQuery Core](https://code.jquery.com/). Here we use it
to obtain jQuery 3.x, but currently 2.x and 1.x are also supported. You
likely won’t need to use this package directly, but packages like
**shiny** and **rmarkdown** will eventually use this package to avoid
bundling redundant copies jQuery.
bundling redundant copies of jQuery.

``` r
jquerylib::jquery_core(3)
Expand Down
1 change: 1 addition & 0 deletions inst/lib/1.12.4/jquery-1.12.4.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions inst/lib/2.2.4/jquery-2.2.4.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions inst/lib/3.6.0/jquery-3.6.0.min.js

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions inst/lib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# jQuery libraries

## Adding a new library

jQuery stopped linking the sourcemap file in jQuery 1.11 and it must be added by hand.

[Source](https://blog.jquery.com/2014/01/24/jquery-1-11-and-2-1-released/)
> but you will need to add the appropriate sourcemap comment at the end of the minified file

### Actions

1. Copy in `.js`, `.min.js`, and `.min.map` files into folder `X.Y.Z`
2. Append the line `//# sourceMappingURL=jquery-X.Y.Z.min.map` to the `X.Y.Z/jquery-X.Y.Z.min.js` file

A `{jquerylib}` test will confirm if this extra step has been performed.
23 changes: 23 additions & 0 deletions tests/testthat/test-sourcemap.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
test_that("sourcemap comments are found", {

expect_sourcemap <- function(version) {
dep <- jquery_core(version, minified = TRUE)

dep_file <- file.path(
htmltools::resolveDependencies(dep)[[1]]$src$file,
dep$script
)

expect_true(file.exists(dep_file))

sourcemap_line <- paste0(
"//# sourceMappingURL=jquery-", expand_version(version), ".min.map"
)

expect_equal(tail(readLines(dep_file), 1), sourcemap_line)
}

expect_sourcemap(1)
expect_sourcemap(2)
expect_sourcemap(3)
})