From e7c97d9cc5e058a072b6c7020e1346957aee5c2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Fri, 26 Feb 2021 16:41:31 +0100 Subject: [PATCH] Automatically register the bootstrapper --- package.json | 2 +- src/index.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d4b0f7a..f7ec499 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@leanadmin/alpine-typescript", - "version": "0.1.4", + "version": "0.1.5", "description": "TypeScript support for Alpine.js", "main": "dist/index.js", "repository": { diff --git a/src/index.ts b/src/index.ts index db9dc8f..a0f04dd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -62,7 +62,7 @@ export function convertClassToAlpineConstructor(component: any): ComponentConstr } } -export default () => { +export function bootstrap(): void { window.AlpineComponents = {}; const deferrer = window.deferLoadingAlpine || function (callback: CallableFunction) { callback() }; @@ -73,3 +73,7 @@ export default () => { deferrer(callback); } } + +if (window.AlpineComponents === undefined) { + bootstrap(); +}