General (ESM)
+Success: 0
+Failure: 0
+Total: 0
+diff --git a/.gitignore b/.gitignore index cf52e28..94a3528 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /node_modules /index.js +/index.esm.js /index.html /perf.html /temp diff --git a/dist.sh b/dist.sh index e140819..79d597c 100755 --- a/dist.sh +++ b/dist.sh @@ -11,18 +11,29 @@ mkdir dist version=$(cat package.json | grep '"version"' | cut -d'"' -f4) file_path="dist/sb.min.js" +file_path_esm="dist/sb.min.esm.js" + file_header="/* Strawberry $version * Copyright (c) 2023-present, Alan Tom (18alantom) * MIT License * This is a generated file. Do not edit.*/" echo "$file_header" >> "$file_path" +echo "$file_header" >> "$file_path_esm" + node_modules/.bin/esbuild ./index.ts --bundle --minify --format=iife --global-name=sb >> "$file_path" +node_modules/.bin/esbuild ./index.ts --bundle --minify --format=esm >> "$file_path_esm" + +print_done() { + size=$(wc -c < $1) + gzsize=$(gzip -c $1 | wc -c) -size=$(wc -c < $file_path) -gzsize=$(gzip -c $file_path | wc -c) + kb=$(echo "scale=3; $size / 1024" | bc) + gzkb=$(echo "scale=3; $gzsize / 1024" | bc) -kb=$(echo "scale=3; $size / 1024" | bc) -gzkb=$(echo "scale=3; $gzsize / 1024" | bc) + path=$(printf "%-18s" $1) + echo "$path :: size: ${kb}KB, gzip: ${gzkb}KB" +} -echo "dist/sb.min.js is ${kb}KB and gzipped ${gzkb}KB" +print_done $file_path +print_done $file_path_esm \ No newline at end of file diff --git a/docs/api.md b/docs/api.md index 349635d..0e0dfce 100644 --- a/docs/api.md +++ b/docs/api.md @@ -14,6 +14,7 @@ This page lists the available strawberry directives and exported methods. 5. [`register`](#register): register custom components. 6. [`load`](#load): load components from external files. 7. [`prefix`](#prefix): change prefix `"sb"` to a custom value. + 8. [`rdo`](#rdo): returns the reactive data object if initialized. ## Directives @@ -301,3 +302,36 @@ if you want to use data attributes to manage directives you can do this:
``` + +### `rdo` + +```typescript +function rdo(): ReactiveObject | null; +``` + +Returns the **r**eactive **d**ata **o**bject if Strawberry has been initialized using +[`sb.init`](#init). + +Useful for when Strawberry is being use as an ESM import where global state is +not shared across module scripts. Example: + +```html + + + +``` diff --git a/docs/reactivity/mark.md b/docs/reactivity/mark.md index a43f6c9..6f87dc7 100644 --- a/docs/reactivity/mark.md +++ b/docs/reactivity/mark.md @@ -165,3 +165,12 @@ If removing elements from the DOM is not what you intend to happen, you can inst > Array items on the other hand can be deleted `delete data.list[0]` but this is > not recommended as it will lead to incorrect sequences of keys, instead use > array operations such as `splice`, `pop`, or `shift`. + +> **Note**: **Deleting Values in Modules** +> +> When using Strawberry as an ESM import. i.e ` + + + +
+
Success: 0
+Failure: 0
+Total: 0
+notset
+ + + +
+
temp
+ + + +notset
+ + +
+