1
0
Fork 0
mirror of https://github.com/archtechx/alpine-typescript.git synced 2025-12-12 06:44:03 +00:00

Fix main in package.json

This commit is contained in:
Samuel Štancl 2021-02-26 15:06:03 +01:00
parent 1260642e07
commit b942524ca1
2 changed files with 4 additions and 6 deletions

View file

@ -70,13 +70,15 @@ component('example', ExampleComponent);
Which will make it accessible using `Alpine.component('example')('foo', 'bar)`.
**Note: It's better to avoid using `Alpine.component('example', ExampleComponent)`** even if it might work in some cases. The reason for this is that `window.Alpine` might not yet be accessible when you're registering components, and if it is, it's possible that it's already evaluated some of the `x-data` attributes.
**Note: It's better to avoid using `Alpine.component('example', ExampleComponent)`** even if it might work in some cases. The reason for this is that `window.Alpine` might not yet be accessible when you're registering components, and if it is, it's possible that it's already evaluated some of the `x-data` attributes. `component()` is guaranteed to work. And of course, you can alias the import if you wish to use a different name.
To register multiple components, you can use the `registerComponents()` helper.
This can pair well with scripts that crawl your e.g. `alpine/` directory to register all components using their file names.
```ts
// alpine/index.js
import { registerComponents } from '@leanadmin/alpine-typescript';
const files = require.context('./', true, /.*.ts/)

View file

@ -2,7 +2,7 @@
"name": "@leanadmin/alpine-typescript",
"version": "0.1.0",
"description": "TypeScript support for Alpine.js",
"main": "src/index.js",
"main": "src/index.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/LeanAdmin/alpine-typescript.git"
@ -10,10 +10,6 @@
"files": [
"src/index.ts"
],
"scripts": {
"build": "npx mix --production",
"prepublishOnly": "npm run-script build"
},
"keywords": [
"alpine",
"alpine.js",