Skip to content

Commit

Permalink
fix: copy source maps for frontend resources (#12701) (#12714)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergey Vinogradov <mr.vursen@gmail.com>
  • Loading branch information
vaadin-bot and vursen committed Jan 13, 2022
1 parent 782ef44 commit b577963
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
*/
public class TaskCopyFrontendFiles implements FallibleCommand {
private static final String[] WILDCARD_INCLUSIONS = new String[] {
"**/*.js", "**/*.css", "**/*.ts" };
"**/*.js", "**/*.js.map", "**/*.css", "**/*.css.map", "**/*.ts",
"**/*.ts.map" };
private static final String WILDCARD_INCLUSION_APP_THEME_JAR = "**/themes/**/*";
private File targetDirectory;
private Set<File> resourceLocations = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ public void setup() throws IOException, ExecutionFailedException {
public void frontendResources_should_beCopiedFromJars_when_TaskUpdatePackagesRemovesThem()
throws IOException, ExecutionFailedException {
copyResources();
assertCopiedFrontendFileAmount(3);
assertCopiedFrontendFileAmount(6/* jar files */ + 1/* package.json */);

performPackageClean();
// Should keep the `package.json` file
assertCopiedFrontendFileAmount(1);

copyResources();
assertCopiedFrontendFileAmount(3);
assertCopiedFrontendFileAmount(6/* jar files */ + 1/* package.json */);
}

private void assertCopiedFrontendFileAmount(int fileCount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,15 @@ private void should_collectJsAndCssFilesFromJars(String jarFile,

// contains:
// - ExampleConnector.js
// - ExampleConnector.js.map
// - inline.css
// - inline.css.map
// - example.ts
// - example.ts.map
File jar = TestUtils.getTestJar(jarFile);
// Contains:
// - resourceInFolder.js
// - resourceInFolder.js.map
File dir = TestUtils.getTestFolder(fsDir);

TaskCopyFrontendFiles task = new TaskCopyFrontendFiles(
Expand All @@ -100,17 +105,36 @@ private void should_collectJsAndCssFilesFromJars(String jarFile,
task.execute();

List<String> files = TestUtils.listFilesRecursively(frontendDepsFolder);
Assert.assertEquals(3, files.size());
Assert.assertEquals(8, files.size());

Assert.assertTrue("Js resource should have been copied from jar file",
Assert.assertTrue("TS resource should have been copied from jar file",
files.contains("example.ts"));

Assert.assertTrue(
"TS resource source map should have been copied from jar file",
files.contains("example.ts.map"));

Assert.assertTrue("JS resource should have been copied from jar file",
files.contains("ExampleConnector.js"));

Assert.assertTrue("Css resource should have been copied from jar file",
Assert.assertTrue(
"JS resource source map should have been copied from jar file",
files.contains("ExampleConnector.js.map"));

Assert.assertTrue("CSS resource should have been copied from jar file",
files.contains("inline.css"));

Assert.assertTrue(
"Js resource should have been copied from resource folder",
"CSS resource source map should have been copied from jar file",
files.contains("inline.css.map"));

Assert.assertTrue(
"JS resource should have been copied from resource folder",
files.contains("resourceInFolder.js"));

Assert.assertTrue(
"JS resource source map should have been copied from resource folder",
files.contains("resourceInFolder.js.map"));
}

private static Set<File> jars(File... files) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified flow-server/src/test/resources/jar-with-frontend-resources.jar
Binary file not shown.
Binary file modified flow-server/src/test/resources/jar-with-modern-frontend.jar
Binary file not shown.

0 comments on commit b577963

Please sign in to comment.