Skip to content

Commit

Permalink
Showing 4 changed files with 47 additions and 30 deletions.
26 changes: 15 additions & 11 deletions packages/addon-dev/src/rollup-gjs-plugin.ts
Original file line number Diff line number Diff line change
@@ -13,17 +13,21 @@ export default function rollupGjsPlugin(
return {
name: PLUGIN_NAME,

transform(input: string, id: string) {
if (!gjsFilter(id)) {
return null;
}
let code = processor.process(input, {
filename: id,
inline_source_map,
});
return {
code,
};
transform: {
// Enforce running the gjs transform before any others like babel that expect valid JS
order: 'pre',
handler(input: string, id: string) {
if (!gjsFilter(id)) {
return null;
}
let code = processor.process(input, {
filename: id,
inline_source_map,
});
return {
code,
};
},
},
};
}
26 changes: 15 additions & 11 deletions packages/addon-dev/src/rollup-hbs-plugin.ts
Original file line number Diff line number Diff line change
@@ -83,18 +83,22 @@ export default function rollupHbsPlugin({
}
},

transform(code: string, id: string) {
let hbsFilename = id.replace(/\.\w{1,3}$/, '') + '.hbs';
if (hbsFilename !== id) {
this.addWatchFile(hbsFilename);
if (getMeta(this, id)?.type === 'template-only-component-js') {
this.addWatchFile(id);
transform: {
// Enforce running the hbs transform before any others like babel that expect valid JS
order: 'pre',
handler(code: string, id: string) {
let hbsFilename = id.replace(/\.\w{1,3}$/, '') + '.hbs';
if (hbsFilename !== id) {
this.addWatchFile(hbsFilename);
if (getMeta(this, id)?.type === 'template-only-component-js') {
this.addWatchFile(id);
}
}
}
if (!hbsFilter(id)) {
return null;
}
return hbsToJS(code);
if (!hbsFilter(id)) {
return null;
}
return hbsToJS(code);
},
},
};
}
14 changes: 9 additions & 5 deletions tests/scenarios/v2-addon-dev-test.ts
Original file line number Diff line number Diff line change
@@ -73,14 +73,17 @@ appScenarios
exclude: ['**/-excluded/**/*'],
}),
addon.dependencies(),
babel({ babelHelpers: 'bundled', extensions: ['.js', '.hbs', '.gjs'] }),
addon.hbs({
excludeColocation: ['**/just-a-template.hbs'],
}),
addon.gjs(),
addon.dependencies(),
addon.publicAssets('public'),
babel({ babelHelpers: 'bundled', extensions: ['.js', '.hbs', '.gjs'] }),
addon.publicAssets('public'),
addon.clean(),
],
@@ -210,10 +213,11 @@ appScenarios
exclude: ['**/-excluded/**/*'],
}),
babel({ babelHelpers: 'bundled', extensions: ['.js', '.hbs', '.gjs'] }),
addon.hbs(),
addon.publicAssets('public', { namespace: '' }),
babel({ babelHelpers: 'bundled', extensions: ['.js', '.hbs', '.gjs'] }),
addon.publicAssets('public', { namespace: '' }),
addon.clean(),
],
11 changes: 8 additions & 3 deletions tests/scenarios/v2-addon-dev-watch-test.ts
Original file line number Diff line number Diff line change
@@ -51,14 +51,19 @@ Scenarios.fromProject(() => baseV2Addon())
plugins: [
addon.publicEntrypoints(['components/**/*.js']),
addon.appReexports(['components/**/*.js']),
addon.gjs(),
addon.hbs(),
addon.dependencies(),
addon.publicAssets('custom-public'),
babel({ babelHelpers: 'bundled' }),
addon.hbs(),
addon.gjs(),
addon.publicAssets('custom-public'),
addon.clean(),
],
};

0 comments on commit 1ac0d49

Please sign in to comment.