Skip to content

Commit

Permalink
fix: optimize iife bundle output
Browse files Browse the repository at this point in the history
  • Loading branch information
luwes committed Mar 26, 2023
1 parent 863448e commit 5bbe537
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lint": "npx eslint src/*.js",
"test": "wet run",
"dev": "wet serve --redirect :examples/ & npm run build -- --watch",
"build": "esbuild src/polyfill.js --global-name=SelectMenuPolyfill --outdir=dist --bundle --minify-syntax --tree-shaking=true",
"build": "esbuild src/polyfill.js --outdir=dist --bundle --minify-syntax --tree-shaking=true",
"prepublishOnly": "npm run build"
},
"devDependencies": {
Expand Down
8 changes: 5 additions & 3 deletions src/option.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ template.innerHTML = /* html */`
`;

class OptionElement extends globalThis.HTMLElement {
static formAssociated = true;
static observedAttributes = ['disabled', 'selected'];

/** @see https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-dirtiness */
#dirty = false;
#internals;
Expand Down Expand Up @@ -146,6 +143,11 @@ class OptionElement extends globalThis.HTMLElement {
}
}

// Define as an external static so esbuild doesn't add unnecessary transforms
// see https://github.com/evanw/esbuild/issues/2416
OptionElement.formAssociated = true;
OptionElement.observedAttributes = ['disabled', 'selected'];

if (!globalThis.customElements.get('x-option')) {
globalThis.customElements.define('x-option', OptionElement);
}
Expand Down
8 changes: 5 additions & 3 deletions src/selectmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,6 @@ template.innerHTML = /* html */`
`;

class SelectMenuElement extends globalThis.HTMLElement {
static formAssociated = true;
static observedAttributes = ['disabled', 'required', 'multiple'];

#internals;

constructor() {
Expand Down Expand Up @@ -464,6 +461,11 @@ class SelectMenuElement extends globalThis.HTMLElement {
}
}

// Define as an external static so esbuild doesn't add unnecessary transforms
// see https://github.com/evanw/esbuild/issues/2416
SelectMenuElement.formAssociated = true;
SelectMenuElement.observedAttributes = ['disabled', 'required', 'multiple'];

function reposition(reference, popover) {

let { style } = getCSSRule(reference.shadowRoot,
Expand Down

1 comment on commit 5bbe537

@vercel
Copy link

@vercel vercel bot commented on 5bbe537 Mar 26, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

selectmenu-polyfill – ./

selectmenu-polyfill-luwes.vercel.app
selectmenu-polyfill.vercel.app
selectmenu-polyfill-git-main-luwes.vercel.app

Please sign in to comment.