diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index bf68ced..0c8054f 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -15,7 +15,7 @@ You should apply this with consideration. You will save up on requests, but doin - ``` diff --git a/docs/introduction.md b/docs/introduction.md index 4866baa..aac4d92 100644 --- a/docs/introduction.md +++ b/docs/introduction.md @@ -13,7 +13,11 @@ The `` component bundles your import on the fly using [Bun](https:// - + ```
diff --git a/src/Components/Import.php b/src/Components/Import.php index cd2cac6..afa6cb0 100644 --- a/src/Components/Import.php +++ b/src/Components/Import.php @@ -53,7 +53,7 @@ protected function raiseConsoleErrorOrException(BundlingFailedException $e) return <<< HTML - + HTML; } @@ -99,7 +99,7 @@ protected function core(): string (() => { // Check if module is already loaded under a different alias - const previous = document.querySelector(`script[data-bundle="{$this->module}"`) + const previous = document.querySelector(`script[data-module="{$this->module}"`) // Was previously loaded & needs to be pushed to import map if(previous && '{$this->as}') { diff --git a/src/Components/views/script.blade.php b/src/Components/views/script.blade.php index 0357a65..1fe6298 100644 --- a/src/Components/views/script.blade.php +++ b/src/Components/views/script.blade.php @@ -2,11 +2,11 @@ @once("bundle:$module:$as") @if ($inline) - @else - + @endif @else {{-- @once else clause --}} diff --git a/tests/Browser/ComponentTest.php b/tests/Browser/ComponentTest.php index b7e13ef..31d1423 100644 --- a/tests/Browser/ComponentTest.php +++ b/tests/Browser/ComponentTest.php @@ -16,7 +16,7 @@ // // HTML) // ->assertScript(<<< JS -// document.querySelectorAll('script[data-bundle="alert"').length +// document.querySelectorAll('script[data-module="alert"').length // JS, 1); class ComponentTest extends DuskTestCase @@ -29,7 +29,7 @@ public function it_renders_the_same_import_only_once() HTML) ->assertScript(<<< 'JS' - document.querySelectorAll('script[data-bundle="~/output-to-id"').length + document.querySelectorAll('script[data-module="~/output-to-id"').length JS, 1); } @@ -41,7 +41,7 @@ public function it_renders_the_same_import_only_once_when_one_was_inlined() HTML) ->assertScript(<<< 'JS' - document.querySelectorAll('script[data-bundle="~/output-to-id"').length + document.querySelectorAll('script[data-module="~/output-to-id"').length JS, 1); } @@ -53,10 +53,10 @@ public function it_renders_multiple_imports_when_they_only_use_a_module_property HTML) ->assertScript(<<< 'JS' - document.querySelectorAll('script[data-bundle="~/function-is-evaluated"').length + document.querySelectorAll('script[data-module="~/function-is-evaluated"').length JS, 1) ->assertScript(<<< 'JS' - document.querySelectorAll('script[data-bundle="~/output-to-id"').length + document.querySelectorAll('script[data-module="~/output-to-id"').length JS, 1); } @@ -68,7 +68,7 @@ public function it_renders_the_same_import_under_different_aliases() HTML) ->assertScript(<<< 'JS' - document.querySelectorAll('script[data-bundle="~/output-to-id"').length + document.querySelectorAll('script[data-module="~/output-to-id"').length JS, 2); } @@ -80,11 +80,11 @@ public function it_renders_script_inline_when_inline_prop_was_passed() HTML) // Assert it doesn't render src attribute on the script tag ->assertScript(<<< 'JS' - document.querySelectorAll('script[data-bundle="~/output-to-id"')[0].hasAttribute('src') + document.querySelectorAll('script[data-module="~/output-to-id"')[0].hasAttribute('src') JS, false) // Assert script tag has content ->assertScript(<<< 'JS' - typeof document.querySelectorAll('script[data-bundle="~/output-to-id"')[0].innerHTML + typeof document.querySelectorAll('script[data-module="~/output-to-id"')[0].innerHTML JS, 'string'); } @@ -95,11 +95,11 @@ public function it_doesnt_render_script_inline_by_default() HTML) // Assert it renders src attribute on the script tag ->assertScript(<<< 'JS' - document.querySelectorAll('script[data-bundle="~/output-to-id"')[0].hasAttribute('src') + document.querySelectorAll('script[data-module="~/output-to-id"')[0].hasAttribute('src') JS, true) // Assert script tag has no content ->assertScript(<<< 'JS' - document.querySelectorAll('script[data-bundle="~/output-to-id"')[0].innerHTML + document.querySelectorAll('script[data-module="~/output-to-id"')[0].innerHTML JS, null); } @@ -194,7 +194,7 @@ public function it_logs_console_errors_when_debug_mode_disabled() HTML) ->assertScript(<<< 'JS' - document.querySelector('script[data-bundle="~/nonexistent-module"').innerHTML + document.querySelector('script[data-module="~/nonexistent-module"').innerHTML JS, 'throw "BUNDLING ERROR: No module found at path \'~/nonexistent-module\'"'); } }