Skip to content

Commit 95198f3

Browse files
authored
Generate ES2017 in development (#1580)
1 parent 3735df6 commit 95198f3

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"preact-cli": minor
3+
---
4+
5+
Generate modern (approximately ES2017) code in development mode to better match production output.

packages/cli/babel/index.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,24 @@ var isProd = (process.env.BABEL_ENV || process.env.NODE_ENV) === 'production';
66
*/
77
var isTest = (process.env.BABEL_ENV || process.env.NODE_ENV) === 'test';
88

9-
// default supported browser.
9+
// default supported browsers for prod nomodule bundles:
1010
var defaultBrowserList = ['> 0.25%', 'IE >= 9'];
1111

12+
// default supported browsers for all dev bundles (module/nomodule is not used):
13+
// see https://github.com/babel/babel/blob/master/packages/babel-compat-data/data/native-modules.json
14+
var defaultBrowserListDev = [
15+
'chrome >= 61',
16+
'and_chr >= 61',
17+
'android >= 61',
18+
'firefox >= 60',
19+
'and_ff >= 60',
20+
'safari >= 10.1',
21+
'ios_saf >= 10.3',
22+
'edge >= 16',
23+
'opera >= 48',
24+
'samsung >= 8.2'
25+
];
26+
1227
// preact-cli babel configs
1328
var babelConfigs = require('../lib/lib/babel-config');
1429

@@ -21,7 +36,7 @@ module.exports = function preactCli(ctx, userOptions = {}) {
2136
var presetOptions = {
2237
env: isProd ? 'production' : 'development',
2338
modules: isTest ? 'commonjs' : false,
24-
browsers: defaultBrowserList,
39+
browsers: isProd ? defaultBrowserList : defaultBrowserListDev,
2540
};
2641

2742
// user specified options always the strongest

packages/cli/lib/lib/babel-config.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = function (env, options = {}) {
66
[
77
require.resolve('@babel/preset-env'),
88
{
9-
loose: true,
9+
bugfixes: true,
1010
modules: options.modules || false,
1111
targets: {
1212
browsers: options.browsers,
@@ -19,10 +19,7 @@ module.exports = function (env, options = {}) {
1919
require.resolve('@babel/plugin-syntax-dynamic-import'),
2020
require.resolve('@babel/plugin-transform-object-assign'),
2121
[require.resolve('@babel/plugin-proposal-decorators'), { legacy: true }],
22-
[
23-
require.resolve('@babel/plugin-proposal-class-properties'),
24-
{ loose: true },
25-
],
22+
require.resolve('@babel/plugin-proposal-class-properties'),
2623
require.resolve('@babel/plugin-proposal-object-rest-spread'),
2724
isProd &&
2825
require.resolve('babel-plugin-transform-react-remove-prop-types'),

packages/cli/tests/service-worker.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe('preact service worker tests', () => {
9191
);
9292
// eslint-disable-next-line no-useless-escape
9393
expect(swText).toMatch(
94-
/caches.match\(\w\("\/200.html"\)\|\|\w\("\/index.html"\)/
94+
/caches.match\(\w+\("\/200.html"\)\|\|\w+\("\/index.html"\)/
9595
);
9696
const page = await browser.newPage();
9797
await page.setCacheEnabled(false);

0 commit comments

Comments
 (0)