|
1 |
| -const browsers = require('./browserslist'); |
2 |
| -const plugins = [ |
3 |
| - ['@babel/plugin-proposal-class-properties'], |
4 |
| - ['@babel/plugin-proposal-object-rest-spread'], |
5 |
| - ['@babel/plugin-syntax-dynamic-import'], |
6 |
| - ['@babel/plugin-syntax-jsx'], |
7 |
| - ['@babel/plugin-transform-react-jsx'], |
8 |
| - ['babel-plugin-graphql-tag'] |
9 |
| -]; |
10 |
| - |
11 |
| -const targets = { |
12 |
| - dev: 'last 2 Chrome versions', |
13 |
| - prod: browsers, |
14 |
| - test: 'node 10' |
15 |
| -}; |
16 |
| - |
17 |
| -const config = api => { |
18 |
| - const envConfigs = { |
19 |
| - /** |
20 |
| - * Watch mode and build:esm partial transpilation mode. |
21 |
| - * The module-resolver plugin makes Babel recognize import paths from |
22 |
| - * package root, like 'src/classify'. |
23 |
| - * |
24 |
| - * BUT VENIA SHOULD NOT USE THEM, because it makes Venia less portable |
25 |
| - * and Venia should be more portable than an average PWA Studio app. |
26 |
| - */ |
27 |
| - development: { |
28 |
| - // Ignore everything with underscores except stories |
29 |
| - ignore: [/\/__(tests?|mocks|fixtures|helpers|dist)__\//], |
30 |
| - plugins: [ |
31 |
| - ...plugins, |
32 |
| - [ |
33 |
| - 'module-resolver', |
34 |
| - { |
35 |
| - root: ['./'], |
36 |
| - /** |
37 |
| - * Exported modules will be consumed by other projects |
38 |
| - * which import Venia. Those projects will need to |
39 |
| - * override the 'src/drivers' dependency so Venia |
40 |
| - * modules will run outside the Venia app. This alias |
41 |
| - * exports the modules so the drivers dependency is |
42 |
| - * a unique string '@magento/venia-drivers', which is |
43 |
| - * less likely to collide with an existing dependency |
44 |
| - * than 'src/drivers' is. |
45 |
| - * |
46 |
| - * In webpack (or any build system) config for a project |
47 |
| - * using Venia modules, you must write an override for |
48 |
| - * '@magento/venia-drivers' and make an alias to that |
49 |
| - * module in your build configuration, e.g.: |
50 |
| - * |
51 |
| - * alias: { |
52 |
| - * '@magento/venia-drivers': './src/veniaDrivers' |
53 |
| - * } |
54 |
| - * |
55 |
| - * to map from this virtual string to your replacement. |
56 |
| - */ |
57 |
| - alias: { |
58 |
| - '^src/drivers$': '@magento/venia-drivers' |
59 |
| - }, |
60 |
| - /** |
61 |
| - * Suppress console warning about missing dependencies. |
62 |
| - */ |
63 |
| - loglevel: 'silent' |
64 |
| - } |
65 |
| - ] |
66 |
| - ], |
67 |
| - presets: [ |
68 |
| - ['@babel/preset-env', { modules: false, targets: targets.dev }] |
69 |
| - ] |
70 |
| - }, |
71 |
| - production: { |
72 |
| - plugins: [ |
73 |
| - ...plugins, |
74 |
| - [ |
75 |
| - '@babel/plugin-transform-runtime', |
76 |
| - { helpers: true, regenerator: true } |
77 |
| - ] |
78 |
| - ], |
79 |
| - presets: [ |
80 |
| - ['@babel/preset-env', { modules: false, targets: targets.prod }] |
81 |
| - ] |
82 |
| - }, |
83 |
| - test: { |
84 |
| - plugins: [...plugins, ['babel-plugin-dynamic-import-node']], |
85 |
| - presets: [ |
86 |
| - [ |
87 |
| - '@babel/preset-env', |
88 |
| - { modules: 'commonjs', targets: targets.test } |
89 |
| - ] |
90 |
| - ] |
91 |
| - } |
| 1 | +module.exports = api => { |
| 2 | + const config = { |
| 3 | + presets: ['@magento/peregrine'], |
| 4 | + exclude: [/packages\/babel\-preset\-peregrine\//] |
92 | 5 | };
|
93 |
| - return envConfigs[api.env() || 'development']; |
| 6 | + if (api.env() === 'development') { |
| 7 | + // Ignore everything with underscores except stories in dev mode |
| 8 | + config.exclude.push(/\/__(tests?|mocks|fixtures|helpers|dist)__\//); |
| 9 | + } |
| 10 | + return config; |
94 | 11 | };
|
95 |
| - |
96 |
| -module.exports = config; |
0 commit comments