From 39a1fb6ed30c966a82a267f2b655f35ef7e8823b Mon Sep 17 00:00:00 2001 From: Doug Parker Date: Sat, 16 Jul 2022 23:05:43 -0700 Subject: [PATCH] Disable PostCSS sourcemaps. Refs #46. This is blocking the Node.js upgrade past v12 and the feature doesn't really work anyways as it isn't currently linked properly in the output. See: https://github.com/bazelbuild/rules_postcss/issues/73/. Hopefully a future migration to Parcel will put us back in a position where CSS sourcemaps can be used. --- packages/rules_prerender/css/css_binaries.bzl | 13 +++++-------- .../css/tests/dependencies/BUILD.bazel | 2 -- .../rules_prerender/css/tests/group/group_test.bzl | 2 -- .../prerender_component_publish_files_test.ts | 1 - 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/packages/rules_prerender/css/css_binaries.bzl b/packages/rules_prerender/css/css_binaries.bzl index 353aaa61..e0fd85eb 100644 --- a/packages/rules_prerender/css/css_binaries.bzl +++ b/packages/rules_prerender/css/css_binaries.bzl @@ -12,7 +12,6 @@ load(":css_providers.bzl", "CssInfo") def css_binaries( name, deps, - sourcemap = True, testonly = None, visibility = None, tags = None, @@ -23,14 +22,13 @@ def css_binaries( "binary", a new CSS file which bundles all the `@import` dependencies of that source. Returns: - `DefaultInfo`: Contains bundled CSS and sourcemaps. + `DefaultInfo`: Contains bundled CSS. `CssImportMapInfo`: Maps importable paths to generated CSS binary files. Args: name: Name of this target. deps: Dependencies of this target which provide `CssInfo` (generally `css_library()`). - sourcemap: Whether to generate sourcemaps (defaults to `True`). testonly: https://docs.bazel.build/versions/main/be/common-definitions.html#common-attributes visibility: https://docs.bazel.build/versions/main/be/common-definitions.html#common-attributes tags: https://docs.bazel.build/versions/main/be/common-definitions.html#common-attributes @@ -40,7 +38,6 @@ def css_binaries( binary_name = "%s_binary_%s" % (name, index) _css_binary( name = binary_name, - sourcemap = sourcemap, dep = dep, testonly = testonly, tags = tags, @@ -67,7 +64,6 @@ def css_binaries( def _css_binary( name, dep, - sourcemap, testonly = None, visibility = None, tags = None, @@ -81,14 +77,13 @@ def _css_binary( an independent "binary", meaning multiple binaries can be generated by this macro. Returns: - `DefaultInfo`: Contains bundled CSS and sourcemaps. + `DefaultInfo`: Contains bundled CSS. `CssImportMapInfo`: Maps importable paths to generated CSS binary files. Args: name: Name of this target. dep: Dependency of this target which provides `CssInfo` (generally `css_library()`). - sourcemap: Whether to generate sourcemaps. testonly: https://docs.bazel.build/versions/main/be/common-definitions.html#common-attributes visibility: https://docs.bazel.build/versions/main/be/common-definitions.html#common-attributes tags: https://docs.bazel.build/versions/main/be/common-definitions.html#common-attributes @@ -111,7 +106,9 @@ def _css_binary( name = binary, srcs = [dep], output_pattern = "{name}", - sourcemap = sourcemap, + # Sourcemaps must be turned off because they don't work on Node.js versions v14+. + # https://github.com/bazelbuild/rules_postcss/issues/73/ + sourcemap = False, plugins = { "//tools/internal:postcss_import_plugin": IMPORT_PLUGIN_CONFIG, }, diff --git a/packages/rules_prerender/css/tests/dependencies/BUILD.bazel b/packages/rules_prerender/css/tests/dependencies/BUILD.bazel index fdf32b5f..55b4c183 100644 --- a/packages/rules_prerender/css/tests/dependencies/BUILD.bazel +++ b/packages/rules_prerender/css/tests/dependencies/BUILD.bazel @@ -12,8 +12,6 @@ diff_test( css_binaries( name = "bin", - # Disable sourcemaps to not confuse `diff_test()` with an extra file. - sourcemap = False, deps = [":foo"], ) diff --git a/packages/rules_prerender/css/tests/group/group_test.bzl b/packages/rules_prerender/css/tests/group/group_test.bzl index 8de35f3c..5e1b4e80 100644 --- a/packages/rules_prerender/css/tests/group/group_test.bzl +++ b/packages/rules_prerender/css/tests/group/group_test.bzl @@ -12,9 +12,7 @@ def _css_group_test_impl(ctx): default_info = analysistest.target_under_test(env)[DefaultInfo] expected_files = sets.make([ "packages/rules_prerender/css/tests/group/lib1.css", - "packages/rules_prerender/css/tests/group/lib1.css.map", "packages/rules_prerender/css/tests/group/lib2.css", - "packages/rules_prerender/css/tests/group/lib2.css.map", ]) actual_files = sets.make([file.short_path for file in default_info.files.to_list()]) asserts.new_set_equals(env, expected_files, actual_files) diff --git a/packages/rules_prerender/prerender_component_publish_files_test.ts b/packages/rules_prerender/prerender_component_publish_files_test.ts index b988913c..27f3a34a 100644 --- a/packages/rules_prerender/prerender_component_publish_files_test.ts +++ b/packages/rules_prerender/prerender_component_publish_files_test.ts @@ -23,7 +23,6 @@ describe('prerender_component_publish_files()', () => { 'script_dep.js.map', 'script_dep.d.ts', 'style.css', - 'style.css.map', 'component_resources', // from `resources` attribute. ]);