Created
May 18, 2021 23:27
-
-
Save bendemboski/907b8a53040213a911301ad48172b99b to your computer and use it in GitHub Desktop.
Webpack config to make ember-power-select work with embroider optimized
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
module: { | |
rules: [ | |
// ember-power-select does a lot of dynamic component acrobatics that | |
// embroider can't statically analyze. Fortunately, we don't actually use | |
// any of the dynamic-ness, so we can just flatten it all to static | |
// invocations. | |
{ | |
test: /\/ember-power-select\/.+\/power-select\.hbs$/, | |
loader: 'string-replace-loader', | |
options: { | |
multiple: [ | |
{ | |
// search: 'let \\(component .*("[^"\n]+").*\\) as \\|', | |
// flags: 'g', | |
search: /let \(component .*("[^"\n]+").*\) as \|/g, | |
replace: 'let (component $1) as |', | |
strict: true, | |
}, | |
{ | |
search: /{{#let \(component @afterOptionsComponent[\s\S]+?{{\/let}}/, | |
replace: '', | |
strict: true, | |
}, | |
{ | |
search: '@triggerComponent={{@ebdTriggerComponent}}', | |
replace: '', | |
strict: true, | |
}, | |
{ | |
search: '@contentComponent={{@ebdContentComponent}}', | |
replace: '', | |
strict: true, | |
}, | |
], | |
}, | |
}, | |
{ | |
test: /\/ember-power-select\/.+\/power-select\/options\.hbs$/, | |
loader: 'string-replace-loader', | |
options: { | |
multiple: [ | |
{ | |
search: '(component @groupComponent)', | |
replace: '(component "power-select/power-select-group")', | |
strict: true, | |
}, | |
{ | |
search: '(component @optionsComponent)', | |
replace: '(component "power-select/options")', | |
strict: true, | |
}, | |
{ | |
search: '@groupComponent={{@groupComponent}}', | |
replace: | |
'@groupComponent={{component "power-select/power-select-group"}}', | |
strict: true, | |
}, | |
{ | |
search: '@optionsComponent={{@optionsComponent}}', | |
replace: '@optionsComponent={{component "power-select/options"}}', | |
strict: true, | |
}, | |
], | |
}, | |
}, | |
{ | |
test: /\/ember-power-select\/.+\/power-select\/trigger\.hbs$/, | |
loader: 'string-replace-loader', | |
options: { | |
multiple: [ | |
{ | |
search: /{{component @selectedItemComponent.+/, | |
replace: '', | |
strict: true, | |
}, | |
{ | |
search: '@placeholderComponent', | |
replace: '"power-select/placeholder"', | |
strict: true, | |
}, | |
], | |
}, | |
}, | |
], | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment