Skip to content

Commit c053f50

Browse files
committed
Introduce more sensible defaults for preact
1 parent bb958ed commit c053f50

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

packages/app/src/sandbox/eval/presets/preact-cli/index.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,45 @@ export default function initialize() {
2727
preactPreset.registerTranspiler(module => /\.jsx?$/.test(module.path), [
2828
{
2929
transpiler: babelTranspiler,
30+
options: {
31+
isV7: false,
32+
compileNodeModulesWithEnv: true,
33+
config: {
34+
presets: [
35+
[
36+
'env',
37+
{
38+
loose: true,
39+
uglify: true,
40+
modules: false,
41+
exclude: [
42+
'transform-regenerator',
43+
'transform-es2015-typeof-symbol',
44+
],
45+
},
46+
],
47+
],
48+
49+
plugins: [
50+
'babel-plugin-syntax-dynamic-import',
51+
'babel-plugin-transform-object-assign',
52+
'babel-plugin-transform-decorators-legacy',
53+
'babel-plugin-transform-class-properties',
54+
'babel-plugin-transform-export-extensions',
55+
'babel-plugin-transform-object-rest-spread',
56+
'babel-plugin-transform-react-constant-elements',
57+
['babel-plugin-transform-react-jsx', { pragma: 'h' }],
58+
[
59+
'babel-plugin-jsx-pragmatic',
60+
{
61+
module: 'preact',
62+
export: 'h',
63+
import: 'h',
64+
},
65+
],
66+
],
67+
},
68+
},
3069
},
3170
]);
3271

packages/common/src/templates/preact.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ export default new Template(
1313
extraConfigurations: {
1414
'/.babelrc': configurations.babelrc,
1515
},
16+
defaultOpenedFile: ['/src/app.js'],
1617
}
1718
);

packages/common/src/templates/template.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export type Options = {
2222
main?: boolean;
2323
backgroundColor?: () => string;
2424
mainFile?: string[];
25+
defaultOpenedFile?: string[];
2526
};
2627

2728
export type ConfigurationFiles = {
@@ -96,6 +97,7 @@ export default class Template {
9697
showCube: boolean;
9798
isServer: boolean;
9899
mainFile: undefined | string[];
100+
defaultOpenedFile: string[];
99101

100102
constructor(
101103
name: TemplateType,
@@ -131,6 +133,7 @@ export default class Template {
131133
this.backgroundColor = options.backgroundColor;
132134

133135
this.showCube = options.showCube != null ? options.showCube : true;
136+
this.defaultOpenedFile = options.defaultOpenedFile || [];
134137
}
135138

136139
// eslint-disable-next-line
@@ -184,7 +187,7 @@ export default class Template {
184187
getDefaultOpenedFiles(
185188
configurationFiles: ParsedConfigurationFiles
186189
): string[] {
187-
return this.getEntries(configurationFiles);
190+
return [...this.defaultOpenedFile, ...this.getEntries(configurationFiles)];
188191
}
189192

190193
/**

0 commit comments

Comments
 (0)