Skip to content

Commit 871092f

Browse files
authored
Merge pull request #133 from umbraco/feature/rollup-hbs-update
Add new package format to plop templates
2 parents 7925766 + 18f9e1c commit 871092f

File tree

6 files changed

+24
-11
lines changed

6 files changed

+24
-11
lines changed

plopfile.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ module.exports = function (plop) {
7979
path: './packages/{{> tagnamePartial }}/package.json',
8080
templateFile: './templates/plop-templates/package.json.hbs',
8181
},
82+
{
83+
type: 'append',
84+
path: './packages/uui/lib/index.ts',
85+
template: "import '@umbraco-ui/{{> tagnamePartial }}/lib';",
86+
},
8287
],
8388
});
8489
};

templates/plop-templates/README.md.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ npm i @umbraco-ui/{{> tagnamePartial}}
1515
Import the registration of `<{{> tagnamePartial}}>` via:
1616

1717
```javascript
18-
import '@umbraco-ui/{{> tagnamePartial}}/lib';
18+
import '@umbraco-ui/{{> tagnamePartial}}';
1919
```
2020

2121
When looking to leverage the `{{className name}}` base class as a type and/or for extension purposes, do so via:
2222

2323
```javascript
24-
import { {{className name}} } from '@umbraco-ui/{{> tagnamePartial}}/lib';
24+
import { {{className name}} } from '@umbraco-ui/{{> tagnamePartial}}';
2525
```
2626

2727
## Usage

templates/plop-templates/component.ts.hbs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { LitElement, html, css } from 'lit';
1+
import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
2+
import { css, html, LitElement } from 'lit';
23

34
/**
45
* @element {{> tagnamePartial }}
56
*/
7+
@defineElement('{{> tagnamePartial }}')
68
export class {{className name}} extends LitElement {
79
static styles = [
810
css`
@@ -17,4 +19,10 @@ export class {{className name}} extends LitElement {
1719
Markup goes here
1820
`;
1921
}
20-
}
22+
}
23+
24+
declare global {
25+
interface HTMLElementTagNameMap {
26+
'{{> tagnamePartial }}': {{className name}} ;
27+
}
28+
}

templates/plop-templates/index.ts.hbs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
import { {{ className name }} } from './{{> tagnamePartial }}.element';
2-
import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
3-
4-
defineElement('{{> tagnamePartial }}', {{ className name }});
5-
61
export * from './{{> tagnamePartial }}.element';

templates/plop-templates/package.json.hbs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919
"bugs": {
2020
"url": "https://github.com/umbraco/Umbraco.UI/issues"
2121
},
22-
"main": "./dist/{{> tagnamePartial }}.min.js",
22+
"main": "./lib/index.js",
2323
"module": "./lib/index.js",
24+
"types": "./lib/index.d.ts",
25+
"type": "module",
2426
"customElements": "custom-elements.json",
2527
"files": [
26-
"dist",
2728
"lib/**/*.d.ts",
2829
"lib/**/*.js",
2930
"custom-elements.json"

templates/plop-templates/test.ts.hbs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ describe('{{className name}}', () => {
1111
);
1212
});
1313

14+
it('is defined with its own instance', () => {
15+
expect(element).to.be.instanceOf({{className name}});
16+
});
17+
1418
it('passes the a11y audit', async () => {
1519
await expect(element).shadowDom.to.be.accessible();
1620
});

0 commit comments

Comments
 (0)