Skip to content

Instantly share code, notes, and snippets.

@bendemboski
Created May 18, 2021 23:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bendemboski/907b8a53040213a911301ad48172b99b to your computer and use it in GitHub Desktop.
Save bendemboski/907b8a53040213a911301ad48172b99b to your computer and use it in GitHub Desktop.
Webpack config to make ember-power-select work with embroider optimized
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