Skip to content

Instantly share code, notes, and snippets.

@royib
royib / object.js
Last active March 2, 2024 16:56
Class article - constructor functions
function Person(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
// Creating a new instance of Person
const newPerson = new Person("john", "duo");
console.log(newPerson.firstName); // Output: john
console.log(newPerson.lastName); // Output: duo
@royib
royib / jest.config.js
Created January 25, 2023 10:21
bazel react jest jest.config.js
module.exports = {
testEnvironment: "node",
testMatch: ["**/*.test.js"],
reporters: ["default", "jest-junit"],
};
@royib
royib / BUILD
Created January 25, 2023 10:19
bazel react test react build file
load("@aspect_rules_jest//jest:defs.bzl", "jest_test")
######Tests#####
jest_test(
name = "test_web",
config = "jest.config.js",
auto_configure_reporters = True,
data = glob(["src/**/*test.js"]) + [":node_modules/jest-junit"],
log_level = "debug",
)
@royib
royib / WORKSPACE
Created January 25, 2023 10:16
bazel react test workspace
########Tetst######
http_archive(
name = "aspect_rules_jest",
sha256 = "abb6bed8b7b22df20d652c60d780cc23e65ffe6c56500d5a9a836a69469f7f99",
strip_prefix = "rules_jest-0.14.3",
url = "https://github.com/aspect-build/rules_jest/archive/refs/tags/v0.14.3.tar.gz",
)
####################
@royib
royib / BUILD
Last active January 25, 2023 10:06
bazel react build file
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@npm//react-project-1:webpack-cli/package_json.bzl", "bin")
npm_link_all_packages(
name = "node_modules",
)
js_library(
name = "lib",
@royib
royib / webpack.config.js
Created January 25, 2023 09:28
bazel react webpack.config.js
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
entry: "./src/index.js",
output: {
filename: "main.js",
path: path.resolve(__dirname, "dist"),
@royib
royib / .bazelignore
Created January 25, 2023 09:05
bazel react .bazelignore
react-project-1/node_modules
@royib
royib / BUILD
Created January 25, 2023 08:54
bazel react build file
load("@npm//:defs.bzl", "npm_link_all_packages")
# Link all packages from the /WORKSPACE npm_translate_lock(name = "npm") and also packages from
# manual /WORKSPACE npm_import rules to bazel-bin/node_modules as well as the virtual store
# bazel-bin/node_modules/.aspect_rules_js since /pnpm-lock.yaml is the root of the pnpm workspace
npm_link_all_packages(
name = "node_modules"
)
@royib
royib / WORKSPACE
Last active January 25, 2023 10:13
bazel react workspace file
workspace(
# see https://docs.bazel.build/versions/main/skylark/deploying.html#workspace
name = "test-workspace",
)
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "aspect_rules_js",
sha256 = "928ba25fa82cfe7983f89118677413dc74dbc5d0360fa969da07ff22a9306052",
@royib
royib / pnpm-workspace.yaml
Created January 25, 2023 07:39
bazel react pnpm-workspace.yaml
packages:
- 'react-project-1'