Bazel Recipes - rollthecloudinc/hedge GitHub Wiki

Fix ESBuild

https://github.com/rollthecloudinc/hedge/issues/211

Must modify two things (files) in cache directory. The first error will be this line 402. The lasecond error will be replacing the last function in the errored file.

npm_install.bzl:402

    generate_config_json = """{
        "exports_directories_only": %s,
        "generate_local_modules_build_files": %s,
        "included_files": %s,
        "links": %s,
        "package_json": "%s",
        "package_lock": "%s",
        "package_path": "%s",
        "rule_type": "%s",
        "strict_visibility": %s,
        "workspace": "%s",
        "workspace_rerooted_path": "%s"
    }""" % (
        "true" if repository_ctx.attr.exports_directories_only else "false",
        "true" if generate_local_modules_build_files else "false",
        str(repository_ctx.attr.included_files),
        str(validated_links),
        str(repository_ctx.path(repository_ctx.attr.package_json)),
        str(repository_ctx.path(lock_file)),
        repository_ctx.attr.package_path,
        rule_type,
        "true" if repository_ctx.attr.strict_visibility else "false",
        repository_ctx.attr.name,
        _WORKSPACE_REROOTED_PATH
    )

helpers.bzl

def write_jsconfig_file(ctx, path_alias_mappings):
    jsconfig = struct(
        compilerOptions = path_alias_mappings,
    )

    jsconfig_contents = """{
        "compilerOptions": %s
    }""" % (
        str(jsconfig.compilerOptions)
    )

    config_file = ctx.actions.declare_file("jsconfig.json")
    ctx.actions.write(
        output = config_file,
        content = jsconfig_contents,
    )
    return config_file