Skip to content

Commit 1d367b6

Browse files
Merge pull request #26 from NxtLvLSoftware/dev-to-dist
Merge dev changes to dist
2 parents ce628ad + 70d6bd0 commit 1d367b6

23 files changed

Lines changed: 347 additions & 160 deletions

.github/workflows/pages-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232

3333
- name: Remove README.md index lines
3434
run: |
35-
sed -i '28,45d' README.md
35+
sed -i '28,46d' README.md
3636
3737
- name: Use Node.js ${{ env.NODE_VERSION }}
3838
uses: actions/setup-node@v3

README.md

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<a href="https://nxtlvlsoftware.github.io/alpine-typescript/"><picture>
33
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/NxtLvLSoftware/alpine-typescript/dist/.github/banner-dark.png">
44
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/NxtLvLSoftware/alpine-typescript/dist/.github/banner-light.png">
5-
<img alt="Project Banner (@nxtlvlsoftware/alpine-typescript)" src="https://raw.githubusercontent.com/NxtLvLSoftware/alpine-typescript/dist/.github/.github/banner-light.png" width="350" height="160" style="max-width: 100%;">
5+
<img alt="Project Banner (@nxtlvlsoftware/alpine-typescript)" src="https://raw.githubusercontent.com/NxtLvLSoftware/alpine-typescript/dist/.github/banner-light.png" width="350" height="160" style="max-width: 100%;">
66
</picture></a>
77
</p>
88

@@ -41,6 +41,7 @@
4141
* [Using Components](#using-components)
4242
* [Contributing](#contributing)
4343
* [Issues](#issues)
44+
* [Pull Requests](#pull-requests)
4445
* [License](#license-information)
4546

4647
<br /><hr /><br />
@@ -59,29 +60,34 @@ $ npm install --save @nxtlvlsoftware/alpine-typescript
5960
```
6061
The package requires manual initialization in the browser as we don't assume a specific use-case:
6162

62-
Using `Alpine.plugin()`:
63+
Using `Alpine.plugin()` (ESModule syntax):
6364
```typescript
6465
import Alpine from 'alpinejs';
6566

6667
window.Alpine = Alpine;
6768

69+
// {default as componentPlugin} also works
6870
import {componentPlugin} from '@nxtlvlsoftware/alpine-typescript';
6971

7072
window.addEventListener('alpine-components:init', () => {
71-
// window.Alpine.Components.register();
73+
window.Alpine.Components.registerAll({
74+
//
75+
});
7276
});
7377

7478
window.Alpine.plugin(componentPlugin);
7579
window.Alpine.start();
7680
```
77-
Using the default export:
81+
Using the default export (CommonJS syntax):
7882
```typescript
7983
import Alpine from 'alpinejs';
8084

8185
window.Alpine = Alpine;
8286

8387
window.addEventListener('alpine-components:init', () => {
84-
// window.Alpine.Components.register();
88+
window.Alpine.Components.registerAll({
89+
//
90+
});
8591
});
8692

8793
window.Alpine.plugin(require('@nxtlvlsoftware/alpine-typescript'));
@@ -90,36 +96,39 @@ window.Alpine.start();
9096
This is the easiest way to get started in existing projects but doesn't offer a way to modify the
9197
default options provided the package.
9298

93-
Using `AlpineComponents.bootstrap()`:
99+
Using `AlpineComponents.bootstrap()` (all examples in ESModule syntax):
94100
```typescript
95-
import Alpine from 'alpinejs';
96-
97-
window.Alpine = Alpine;
98-
99101
import {AlpineComponents} from '@nxtlvlsoftware/alpine-typescript';
100102

101103
AlpineComponents.bootstrap({
104+
bootstrapAlpine: true,
102105
components: {
103106
//
104-
}});
107+
}
108+
});
105109
```
106-
The default options are best suited to new projects and automatically starts Alpine for you.
107-
To integrate into existing projects seamlessly, just pass in an options object:
110+
The default options are best suited to new projects as `Alpine.start()` will be called for you.
111+
To integrate into existing projects seamlessly, just set `startAlpine` to `false` on the options
112+
object:
108113
```typescript
114+
import Alpine from 'alpinejs';
115+
116+
window.Alpine = Alpine;
117+
109118
import {AlpineComponents} from '@nxtlvlsoftware/alpine-typescript';
110119

111120
AlpineComponents.bootstrap({
121+
startAlpine: false,
122+
logErrors: true, // should only enable this in dev enviroments for debugging
112123
components: {
113124
//
114-
},
115-
startAlpine: false,
116-
logErrors: true // should only enable this in dev enviroments for debugging
117-
}); // pass the Alpine object explicity if you aren't following the default convention
125+
}
126+
});
118127

119128
window.Alpine.start();
120129
```
121-
If you aren't following the default convention of defining `window.Alpine` after importing Alpine
122-
just pass it after your options object:
130+
If you aren't following the default convention of defining `window.Alpine` after importing Alpine,
131+
just pass it as the second argument to the `AlpineComponents.bootstrap()` call:
123132
```typescript
124133
import Alpine from 'alpinejs';
125134

@@ -129,10 +138,10 @@ import {AlpineComponents} from '@nxtlvlsoftware/alpine-typescript';
129138

130139
const isProduction = () => false; // equivelent would be injected/definied server-side by your framework
131140
AlpineComponents.bootstrap({
132-
components: {
133-
//
134-
},
135-
logErrors: !isProduction()
141+
components: {
142+
//
143+
},
144+
logErrors: !isProduction()
136145
}, myAlpine);
137146

138147
// might break alpine or other packages by defining after init but we support it ¯\_(ツ)_/¯
@@ -469,15 +478,23 @@ The main drawback of using this library is the added compilation step needed to
469478
Alpine is an elegant library that provides a thin layer on-top of vanilla JavaScript. Using
470479
Alpine the way it was intended is the way to go until your list of components grows and you
471480
need a way to organise them. If you're not already using a bundler in your project (webpack,
472-
Vite, Rollup, etc) then this probably isn't for you.
481+
Vite, Rollup, etc.) then this probably isn't for you.
473482

474483
## Contributing
475-
476484
#### Issues
477-
478485
Found a problem with this project? Make sure to open an issue on the [issue tracker](https://github.com/NxtLvLSoftware/alpine-typescript/issues)
479486
and we'll do our best to get it sorted!
480487

488+
#### Pull Requests
489+
Pull requests will be reviewed by maintainers when they are available.
490+
491+
Depending on the changes, maintainers might ask you to make changes to the PR to fix problems
492+
or to improve the code. Do not delete your fork while your pull request remains open, otherwise
493+
you won't be able to make any requested changes and the PR will end up being declined.
494+
495+
By proposing a pull request, you agree to your code being distributed under [this projects license](https://github.com/NxtLvlSoftware/alpine-typescript/blob/dev/LICENSE).
496+
497+
481498
## License Information
482499

483500
[`nxtlvlsoftware/alpine-typescript`](https://github.com/NxtLvlSoftware/alpine-typescript) is open-sourced software,

examples/package/package.json

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
{
22
"name": "alpine-typescript-package-example",
3-
"type": "module",
4-
"version": "0.0.1",
53
"description": "Example Alpine.js components package.",
6-
"author": "Jack Noordhuis <me@jacknoordhuis.net>",
4+
"version": "0.0.1",
75
"license": "MIT",
6+
"author": {
7+
"name": "Jack Noordhuis",
8+
"email": "me@jacknoordhuis.net",
9+
"url": "https://jacknoordhuis.net"
10+
},
11+
"keywords": [
12+
"component",
13+
"alpine",
14+
"javascript",
15+
"typescript",
16+
"js",
17+
"ts"
18+
],
19+
"repository": "NxtLvlSoftware/alpine-typescript",
20+
"homepage": "https://nxtlvlsoftware.github.io/alpine-typescript/",
21+
"bugs": {
22+
"url": "https://github.com/NxtLvlSoftware/alpine-typescript/issues"
23+
},
24+
"type": "module",
825
"main": "index.js",
926
"files": [
10-
"index.ts",
1127
"index.d.ts",
1228
"index.js",
13-
"src/**/*.ts",
1429
"src/**/*.d.ts",
1530
"src/**/*.js"
1631
],
@@ -19,14 +34,6 @@
1934
"build-ci": "tsc --pretty false --inlineSourceMap --removeComments --listEmittedFiles -p ./",
2035
"dev": "tsc --watch -p ./"
2136
},
22-
"keywords": [
23-
"component",
24-
"alpine",
25-
"javascript",
26-
"typescript",
27-
"js",
28-
"ts"
29-
],
3037
"dependencies": {
3138
"@nxtlvlsoftware/alpine-typescript": "file:../../",
3239
"@types/alpinejs": "^3.7.2"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const advancedPreset = require('cssnano-preset-advanced');
2+
3+
module.exports = advancedPreset({
4+
discardComments: {
5+
removeAll: true,
6+
}
7+
});

0 commit comments

Comments
 (0)