Skip to content

use @pika/pack to build ESM, UMD #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
pkg/
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
node_js: 6.3
node_js: 8
before_script:
- npm install -g testee
- npm run build
script: npm test
before_install:
- "export DISPLAY=:99.0"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import customAttributes from 'custom-attributes';
Or you can just import the CustomAttributeRegistry and create your own instance:

```js
import CustomAttributeRegistry from 'custom-attributes/registry';
import {CustomAttributeRegistry} from 'custom-attributes';

const customAttributes = new CustomAttributeRegistry(document);
```
Expand Down Expand Up @@ -59,7 +59,7 @@ class BgColor {
}
}

customAttributes.define('bg-color', BgColor);
customAttributes.default.define('bg-color', BgColor);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, yeah I don't want to have to do this... Will look for a way around.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, curious if you have any thoughts. Moving to ESM in your examples would definitely move people in that direction, but I didn’t see anything in rollup that lets you define your UMD module as an actual function

```

## API
Expand Down
1 change: 0 additions & 1 deletion attr.html

This file was deleted.

147 changes: 0 additions & 147 deletions attr.js

This file was deleted.

4 changes: 0 additions & 4 deletions global.js

This file was deleted.

19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@
"version": "1.1.3",
"description": "Custom attributes, like custom elements, but for attributes",
"main": "index.js",
"@pika/pack": {
"pipeline": [
["@pika/plugin-standard-pkg"],
["@pika/plugin-build-web"],
["@pika/plugin-build-umd", {"name": "customAttributes"}]
]
},
"directories": {
"test": "test"
},
"scripts": {
"build": "pack build",
"test": "testee test/connect.html test/disconnect.html test/change.html --browsers firefox"
},
"repository": {
Expand All @@ -17,20 +25,17 @@
"web",
"components"
],
"files": [
"attr.js",
"attr.html",
"global.js",
"index.js",
"registry.js"
],
"author": "Matthew Phillips",
"license": "BSD-2-Clause",
"bugs": {
"url": "https://github.com/matthewp/custom-attributes/issues"
},
"homepage": "https://github.com/matthewp/custom-attributes#readme",
"devDependencies": {
"@pika/pack": "^0.2.2",
"@pika/plugin-build-umd": "^0.3.7",
"@pika/plugin-build-web": "^0.3.7",
"@pika/plugin-standard-pkg": "^0.3.7",
"mocha-test": "^1.0.3",
"rollup": "^0.41.4",
"testee": "^0.3.0",
Expand Down
1 change: 0 additions & 1 deletion index.js → src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import CustomAttributeRegistry from './registry.js';

var customAttributes = new CustomAttributeRegistry(document);

export { customAttributes as default, CustomAttributeRegistry }
File renamed without changes.
6 changes: 3 additions & 3 deletions test/change.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>changedCallback() tests</title>

<script src="../node_modules/webcomponents.js/webcomponents-lite.min.js" defer></script>
<script src="../attr.js" defer></script>
<script src="../pkg/dist-umd/index.js" defer></script>
<link rel="import" href="../node_modules/mocha-test/mocha-test.html" defer>
</head>
<body>
Expand All @@ -29,7 +29,7 @@
}
}

customAttributes.define('some-attr', SomeAttr);
customAttributes.default.define('some-attr', SomeAttr);

var el = document.createElement('article');
el.setAttribute('some-attr', 'foo');
Expand All @@ -47,7 +47,7 @@
}
}

customAttributes.define('another-attr', AnotherAttr);
customAttributes.default.define('another-attr', AnotherAttr);

var el = document.createElement('span');
el.setAttribute('another-attr', 'foo');
Expand Down
4 changes: 2 additions & 2 deletions test/connect.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title> simple test</title>

<script src="../node_modules/webcomponents.js/webcomponents-lite.min.js" defer></script>
<script src="../attr.js"></script>
<script src="../pkg/dist-umd/index.js"></script>
<link rel="import" href="../node_modules/mocha-test/mocha-test.html">
</head>
<body>
Expand Down Expand Up @@ -32,7 +32,7 @@
}
}

customAttributes.define('bg-color', BgColorAttr);
customAttributes.default.define('bg-color', BgColorAttr);
})();
</script>

Expand Down
6 changes: 3 additions & 3 deletions test/disconnect.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>disconnectedCallback() tests</title>

<script src="../node_modules/webcomponents.js/webcomponents-lite.min.js" defer></script>
<script src="../attr.js" defer></script>
<script src="../pkg/dist-umd/index.js" defer></script>
<link rel="import" href="../node_modules/mocha-test/mocha-test.html" defer>
</head>
<body>
Expand Down Expand Up @@ -40,7 +40,7 @@
}
}

customAttributes.define('my-attr', MyAttr);
customAttributes.default.define('my-attr', MyAttr);

var el = document.createElement('span');
fixture.appendChild(el);
Expand All @@ -62,7 +62,7 @@
}
}

customAttributes.define('some-attr', SomeAttr);
customAttributes.default.define('some-attr', SomeAttr);

var el = document.createElement('span');
fixture.appendChild(el);
Expand Down
6 changes: 3 additions & 3 deletions test/get.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>get() tests</title>

<script src="../node_modules/webcomponents.js/webcomponents-lite.min.js" defer></script>
<script src="../attr.js" defer></script>
<script src="../pkg/dist-umd/index.js" defer></script>
<link rel="import" href="../node_modules/mocha-test/mocha-test.html" defer>
</head>
<body>
Expand All @@ -23,7 +23,7 @@

it('gets the attribute instance', function(done){
class Foobar {}
customAttributes.define('foo-bar', Foobar);
customAttributes.default.define('foo-bar', Foobar);

var el = document.createElement('span');
el.setAttribute('foo-bar', 'baz');
Expand All @@ -43,7 +43,7 @@
done();
}
}
customAttributes.define('foo-bar', Foobar);
customAttributes.default.define('foo-bar', Foobar);

var el = document.createElement('span');
el.setAttribute('foo-bar', 'bam');
Expand Down