@bryntum/babel-preset-react-app 7.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2013-present, Facebook, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,46 @@
1
+ # @bryntum/babel-preset-react-app
2
+ This repo is part of `create-react-app` fork localed at https://github.com/bryntum/create-react-app/tree/master/packages/babel-preset-react-app.
3
+
4
+ # Bryntum Repository access setup
5
+
6
+ This npm package requires access to Bryntum private NPM repository.
7
+ You must be logged-in to this repository as a licensed or trial user to access it.
8
+ Please check [Online npm repository guide](https://bryntum.com/products/grid/docs/guide/Grid/npm-repository) for
9
+ detailed information on the sign-up/login process.
10
+
11
+ # React demo performance
12
+
13
+ Bryntum React demo applications use CRA scripts for project compilation.
14
+ CRA by default use `@babel/plugin-transform-runtime` plugin to transpile application's *.js library dependencies.
15
+ This finally affects on built React application performance which is seriously degraded when used with Bryntum library where async function generators are widely used.
16
+
17
+ # Workaround
18
+
19
+ CRA has no build-in config options which allow to disable this behavior.
20
+ We have created our fork for CRA to fix this issue and disable unwanted library transpilation.
21
+ `dependencies.js` contains patched copy of original presets with disabled preset plugins.
22
+
23
+ # Browser compatibility notice
24
+
25
+ React application which is build with this preset patch will be incompatible with IE11 or non-chromium legacy Edge.
26
+
27
+ # Links
28
+
29
+ Original CRA scripts
30
+ https://github.com/facebook/create-react-app
31
+
32
+ Alternatives to Ejecting
33
+ https://create-react-app.dev/docs/alternatives-to-ejecting/
34
+
35
+ Customizing create-react-app: How to Make Your Own Template
36
+ https://auth0.com/blog/how-to-configure-create-react-app/
37
+
38
+ # Online References
39
+
40
+ * [React Framework](https://github.com/facebook/create-react-app)
41
+ * [Bryntum React integration guide](https://bryntum.com/products/grid/docs/guide/Grid/integration/react)
42
+ * [Bryntum Grid documentation](https://bryntum.com/products/grid/docs/)
43
+ * [Bryntum Grid examples](https://bryntum.com/products/grid/examples/)
44
+ * [Bryntum npm repository guide](https://bryntum.com/products/grid/docs/guide/Grid/npm-repository)
45
+ * [Bryntum support Forum](https://forum.bryntum.com/)
46
+ * [Contacts us](https://bryntum.com/contact/)
package/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # babel-preset-react-app
2
+
3
+ This package includes the Babel preset used by [Create React App](https://github.com/facebook/create-react-app).<br>
4
+ Please refer to its documentation:
5
+
6
+ - [Getting Started](https://facebook.github.io/create-react-app/docs/getting-started) – How to create a new app.
7
+ - [User Guide](https://facebook.github.io/create-react-app/) – How to develop apps bootstrapped with Create React App.
8
+
9
+ ## Usage in Create React App Projects
10
+
11
+ The easiest way to use this configuration is with [Create React App](https://github.com/facebook/create-react-app), which includes it by default. **You don’t need to install it separately in Create React App projects.**
12
+
13
+ ## Usage Outside of Create React App
14
+
15
+ If you want to use this Babel preset in a project not built with Create React App, you can install it with the following steps.
16
+
17
+ First, [install Babel](https://babeljs.io/docs/setup/).
18
+
19
+ Then install babel-preset-react-app.
20
+
21
+ ```sh
22
+ npm install babel-preset-react-app --save-dev
23
+ ```
24
+
25
+ Then create a file named `.babelrc` with the following contents in the root folder of your project:
26
+
27
+ ```json
28
+ {
29
+ "presets": ["react-app"]
30
+ }
31
+ ```
32
+
33
+ This preset uses the `useBuiltIns` option with [transform-object-rest-spread](http://babeljs.io/docs/plugins/transform-object-rest-spread/) and [transform-react-jsx](http://babeljs.io/docs/plugins/transform-react-jsx/), which assumes that `Object.assign` is available or polyfilled.
34
+
35
+ ## Usage with Flow
36
+
37
+ Make sure you have a `.flowconfig` file at the root directory. You can also use the `flow` option on `.babelrc`:
38
+
39
+ ```json
40
+ {
41
+ "presets": [["react-app", { "flow": true, "typescript": false }]]
42
+ }
43
+ ```
44
+
45
+ ## Usage with TypeScript
46
+
47
+ Make sure you have a `tsconfig.json` file at the root directory. You can also use the `typescript` option on `.babelrc`:
48
+
49
+ ```json
50
+ {
51
+ "presets": [["react-app", { "flow": false, "typescript": true }]]
52
+ }
53
+ ```
54
+
55
+ ## Absolute Runtime Paths
56
+
57
+ Absolute paths are enabled by default for imports. To use relative paths instead, set the `absoluteRuntime` option in `.babelrc` to `false`:
58
+ ```
59
+
60
+ {
61
+ "presets": [["react-app", { "absoluteRuntime": false }]]
62
+ }
63
+ ```
package/create.js ADDED
@@ -0,0 +1,208 @@
1
+ /**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ const path = require('path');
9
+
10
+ const validateBoolOption = (name, value, defaultValue) => {
11
+ if (typeof value === 'undefined') {
12
+ value = defaultValue;
13
+ }
14
+
15
+ if (typeof value !== 'boolean') {
16
+ throw new Error(`Preset react-app: '${name}' option must be a boolean.`);
17
+ }
18
+
19
+ return value;
20
+ };
21
+
22
+ module.exports = function(api, opts, env) {
23
+ if (!opts) {
24
+ opts = {};
25
+ }
26
+
27
+ const isEnvDevelopment = env === 'development';
28
+ const isEnvProduction = env === 'production';
29
+ const isEnvTest = env === 'test';
30
+
31
+ const useESModules = validateBoolOption(
32
+ 'useESModules',
33
+ opts.useESModules,
34
+ isEnvDevelopment || isEnvProduction
35
+ );
36
+ const isFlowEnabled = validateBoolOption('flow', opts.flow, true);
37
+ const isTypeScriptEnabled = validateBoolOption(
38
+ 'typescript',
39
+ opts.typescript,
40
+ true
41
+ );
42
+ const areHelpersEnabled = validateBoolOption('helpers', opts.helpers, true);
43
+ const useAbsoluteRuntime = validateBoolOption(
44
+ 'absoluteRuntime',
45
+ opts.absoluteRuntime,
46
+ true
47
+ );
48
+
49
+ let absoluteRuntimePath;
50
+ if (useAbsoluteRuntime) {
51
+ absoluteRuntimePath = path.dirname(
52
+ require.resolve('@babel/runtime/package.json')
53
+ );
54
+ }
55
+
56
+ if (!isEnvDevelopment && !isEnvProduction && !isEnvTest) {
57
+ throw new Error(
58
+ 'Using `babel-preset-react-app` requires that you specify `NODE_ENV` or ' +
59
+ '`BABEL_ENV` environment variables. Valid values are "development", ' +
60
+ '"test", and "production". Instead, received: ' +
61
+ JSON.stringify(env) +
62
+ '.'
63
+ );
64
+ }
65
+
66
+ return {
67
+ presets : [
68
+ isEnvTest && [
69
+ // ES features necessary for user's Node version
70
+ require('@babel/preset-env').default,
71
+ {
72
+ targets : {
73
+ node : 'current'
74
+ }
75
+ }
76
+ ],
77
+ (isEnvProduction || isEnvDevelopment) && [
78
+ // Latest stable ECMAScript features
79
+ require('@babel/preset-env').default,
80
+ {
81
+ // Allow importing core-js in entrypoint and use browserlist to select polyfills
82
+ useBuiltIns : 'entry',
83
+ // Set the corejs version we are using to avoid warnings in console
84
+ corejs : 3,
85
+ // Exclude transforms that make all code slower
86
+ exclude : ['transform-typeof-symbol']
87
+ }
88
+ ],
89
+ [
90
+ require('@babel/preset-react').default,
91
+ {
92
+ // Adds component stack to warning messages
93
+ // Adds __self attribute to JSX which React will use for some warnings
94
+ development : isEnvDevelopment || isEnvTest,
95
+ // Will use the native built-in instead of trying to polyfill
96
+ // behavior for any plugins that require one.
97
+ ...(opts.runtime !== 'automatic' ? { useBuiltIns : true } : {}),
98
+ runtime : opts.runtime || 'classic'
99
+ }
100
+ ],
101
+ isTypeScriptEnabled && [require('@babel/preset-typescript').default]
102
+ ].filter(Boolean),
103
+ plugins : [
104
+ // Strip flow types before any other transform, emulating the behavior
105
+ // order as-if the browser supported all of the succeeding features
106
+ // https://github.com/facebook/create-react-app/pull/5182
107
+ // We will conditionally enable this plugin below in overrides as it clashes with
108
+ // @babel/plugin-proposal-decorators when using TypeScript.
109
+ // https://github.com/facebook/create-react-app/issues/5741
110
+ isFlowEnabled && [
111
+ require('@babel/plugin-transform-flow-strip-types').default,
112
+ false
113
+ ],
114
+ // Experimental macros support. Will be documented after it's had some time
115
+ // in the wild.
116
+ require('babel-plugin-macros'),
117
+ // Disabled as it's handled automatically by preset-env, and `selectiveLoose` isn't
118
+ // yet merged into babel: https://github.com/babel/babel/pull/9486
119
+ // Related: https://github.com/facebook/create-react-app/pull/8215
120
+ // [
121
+ // require('@babel/plugin-transform-destructuring').default,
122
+ // {
123
+ // // Use loose mode for performance:
124
+ // // https://github.com/facebook/create-react-app/issues/5602
125
+ // loose: false,
126
+ // selectiveLoose: [
127
+ // 'useState',
128
+ // 'useEffect',
129
+ // 'useContext',
130
+ // 'useReducer',
131
+ // 'useCallback',
132
+ // 'useMemo',
133
+ // 'useRef',
134
+ // 'useImperativeHandle',
135
+ // 'useLayoutEffect',
136
+ // 'useDebugValue',
137
+ // ],
138
+ // },
139
+ // ],
140
+ // Turn on legacy decorators for TypeScript files
141
+ isTypeScriptEnabled && [
142
+ require('@babel/plugin-proposal-decorators').default,
143
+ false
144
+ ],
145
+ // class { handleClick = () => { } }
146
+ // Enable loose mode to use assignment instead of defineProperty
147
+ // See discussion in https://github.com/facebook/create-react-app/issues/4263
148
+ [
149
+ require('@babel/plugin-proposal-class-properties').default,
150
+ {
151
+ loose : true
152
+ }
153
+ ],
154
+ // Adds Numeric Separators
155
+ require('@babel/plugin-proposal-numeric-separator').default,
156
+ // Polyfills the runtime needed for async/await, generators, and friends
157
+ // https://babeljs.io/docs/en/babel-plugin-transform-runtime
158
+ [
159
+ require('@babel/plugin-transform-runtime').default,
160
+ {
161
+ corejs : false,
162
+ helpers : areHelpersEnabled,
163
+ // By default, babel assumes babel/runtime version 7.0.0-beta.0,
164
+ // explicitly resolving to match the provided helper functions.
165
+ // https://github.com/babel/babel/issues/10261
166
+ version : require('@babel/runtime/package.json').version,
167
+ regenerator : true,
168
+ // https://babeljs.io/docs/en/babel-plugin-transform-runtime#useesmodules
169
+ // We should turn this on once the lowest version of Node LTS
170
+ // supports ES Modules.
171
+ useESModules,
172
+ // Undocumented option that lets us encapsulate our runtime, ensuring
173
+ // the correct version is used
174
+ // https://github.com/babel/babel/blob/090c364a90fe73d36a30707fc612ce037bdbbb24/packages/babel-plugin-transform-runtime/src/index.js#L35-L42
175
+ absoluteRuntime : absoluteRuntimePath
176
+ }
177
+ ],
178
+ isEnvProduction && [
179
+ // Remove PropTypes from production build
180
+ require('babel-plugin-transform-react-remove-prop-types').default,
181
+ {
182
+ removeImport : true
183
+ }
184
+ ],
185
+ // Optional chaining and nullish coalescing are supported in @babel/preset-env,
186
+ // but not yet supported in webpack due to support missing from acorn.
187
+ // These can be removed once webpack has support.
188
+ // See https://github.com/facebook/create-react-app/issues/8445#issuecomment-588512250
189
+ require('@babel/plugin-proposal-optional-chaining').default,
190
+ require('@babel/plugin-proposal-nullish-coalescing-operator').default
191
+ ].filter(Boolean),
192
+ overrides : [
193
+ isFlowEnabled && {
194
+ exclude : /\.tsx?$/,
195
+ plugins : [require('@babel/plugin-transform-flow-strip-types').default]
196
+ },
197
+ isTypeScriptEnabled && {
198
+ test : /\.tsx?$/,
199
+ plugins : [
200
+ [
201
+ require('@babel/plugin-proposal-decorators').default,
202
+ { legacy : true }
203
+ ]
204
+ ]
205
+ }
206
+ ].filter(Boolean)
207
+ };
208
+ };
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ const path = require('path');
9
+
10
+ const validateBoolOption = (name, value, defaultValue) => {
11
+ if (typeof value === 'undefined') {
12
+ value = defaultValue;
13
+ }
14
+
15
+ if (typeof value !== 'boolean') {
16
+ throw new Error(`Preset react-app: '${name}' option must be a boolean.`);
17
+ }
18
+
19
+ return value;
20
+ };
21
+
22
+ module.exports = function(api, opts) {
23
+ if (!opts) {
24
+ opts = {};
25
+ }
26
+
27
+ // This is similar to how `env` works in Babel:
28
+ // https://babeljs.io/docs/usage/babelrc/#env-option
29
+ // We are not using `env` because it’s ignored in versions > babel-core@6.10.4:
30
+ // https://github.com/babel/babel/issues/4539
31
+ // https://github.com/facebook/create-react-app/issues/720
32
+ // It’s also nice that we can enforce `NODE_ENV` being specified.
33
+ const env = process.env.BABEL_ENV || process.env.NODE_ENV;
34
+ const isEnvDevelopment = env === 'development';
35
+ const isEnvProduction = env === 'production';
36
+ const isEnvTest = env === 'test';
37
+
38
+ const areHelpersEnabled = validateBoolOption('helpers', opts.helpers, false);
39
+ const useAbsoluteRuntime = validateBoolOption(
40
+ 'absoluteRuntime',
41
+ opts.absoluteRuntime,
42
+ true
43
+ );
44
+
45
+ let absoluteRuntimePath;
46
+ if (useAbsoluteRuntime) {
47
+ absoluteRuntimePath = path.dirname(
48
+ require.resolve('@babel/runtime/package.json')
49
+ );
50
+ }
51
+
52
+ if (!isEnvDevelopment && !isEnvProduction && !isEnvTest) {
53
+ throw new Error(
54
+ 'Using `babel-preset-react-app` requires that you specify `NODE_ENV` or ' +
55
+ '`BABEL_ENV` environment variables. Valid values are "development", ' +
56
+ '"test", and "production". Instead, received: ' +
57
+ JSON.stringify(env) +
58
+ '.'
59
+ );
60
+ }
61
+
62
+ return {
63
+ // Babel assumes ES Modules, which isn't safe until CommonJS
64
+ // dies. This changes the behavior to assume CommonJS unless
65
+ // an `import` or `export` is present in the file.
66
+ // https://github.com/webpack/webpack/issues/4039#issuecomment-419284940
67
+ sourceType : 'unambiguous',
68
+ presets : [
69
+ isEnvTest && [
70
+ // ES features necessary for user's Node version
71
+ require('@babel/preset-env').default,
72
+ {
73
+ targets : {
74
+ node : 'current'
75
+ },
76
+ // Exclude transforms that make all code slower
77
+ exclude : ['transform-typeof-symbol']
78
+ }
79
+ ],
80
+ (isEnvProduction || isEnvDevelopment) && [
81
+ // Latest stable ECMAScript features
82
+ require('@babel/preset-env').default,
83
+ {
84
+ // Allow importing core-js in entrypoint and use browserlist to select polyfills
85
+ useBuiltIns : 'entry',
86
+ // Set the corejs version we are using to avoid warnings in console
87
+ // This will need to change once we upgrade to corejs@3
88
+ corejs : 3,
89
+ // Exclude transforms that make all code slower
90
+ exclude : ['transform-typeof-symbol']
91
+ }
92
+ ]
93
+ ].filter(Boolean),
94
+ plugins : [
95
+ // Disabled as it's handled automatically by preset-env, and `selectiveLoose` isn't
96
+ // yet merged into babel: https://github.com/babel/babel/pull/9486
97
+ // Related: https://github.com/facebook/create-react-app/pull/8215
98
+ // [
99
+ // require('@babel/plugin-transform-destructuring').default,
100
+ // {
101
+ // // Use loose mode for performance:
102
+ // // https://github.com/facebook/create-react-app/issues/5602
103
+ // loose: false,
104
+ // selectiveLoose: [
105
+ // 'useState',
106
+ // 'useEffect',
107
+ // 'useContext',
108
+ // 'useReducer',
109
+ // 'useCallback',
110
+ // 'useMemo',
111
+ // 'useRef',
112
+ // 'useImperativeHandle',
113
+ // 'useLayoutEffect',
114
+ // 'useDebugValue',
115
+ // ],
116
+ // },
117
+ // ],
118
+ // Polyfills the runtime needed for async/await, generators, and friends
119
+ // https://babeljs.io/docs/en/babel-plugin-transform-runtime
120
+ // [
121
+ // require('@babel/plugin-transform-runtime').default,
122
+ // {
123
+ // corejs: false,
124
+ // helpers: areHelpersEnabled,
125
+ // // By default, babel assumes babel/runtime version 7.0.0-beta.0,
126
+ // // explicitly resolving to match the provided helper functions.
127
+ // // https://github.com/babel/babel/issues/10261
128
+ // version: require('@babel/runtime/package.json').version,
129
+ // regenerator: true,
130
+ // // https://babeljs.io/docs/en/babel-plugin-transform-runtime#useesmodules
131
+ // // We should turn this on once the lowest version of Node LTS
132
+ // // supports ES Modules.
133
+ // useESModules: isEnvDevelopment || isEnvProduction,
134
+ // // Undocumented option that lets us encapsulate our runtime, ensuring
135
+ // // the correct version is used
136
+ // // https://github.com/babel/babel/blob/090c364a90fe73d36a30707fc612ce037bdbbb24/packages/babel-plugin-transform-runtime/src/index.js#L35-L42
137
+ // absoluteRuntime: absoluteRuntimePath,
138
+ // },
139
+ // ],
140
+ ].filter(Boolean)
141
+ };
142
+ };
package/dev.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ const create = require('./create');
9
+
10
+ module.exports = function(api, opts) {
11
+ return create(api, Object.assign({ helpers : false }, opts), 'development');
12
+ };
package/index.js ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ const create = require('./create');
9
+
10
+ module.exports = function(api, opts) {
11
+ // This is similar to how `env` works in Babel:
12
+ // https://babeljs.io/docs/usage/babelrc/#env-option
13
+ // We are not using `env` because it’s ignored in versions > babel-core@6.10.4:
14
+ // https://github.com/babel/babel/issues/4539
15
+ // https://github.com/facebook/create-react-app/issues/720
16
+ // It’s also nice that we can enforce `NODE_ENV` being specified.
17
+ const env = process.env.BABEL_ENV || process.env.NODE_ENV;
18
+ return create(api, opts, env);
19
+ };
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@bryntum/babel-preset-react-app",
3
+ "version": "7.1.1",
4
+ "description": "Babel preset used by Create React App. Patched for Bryntum products",
5
+ "author": {
6
+ "name": "Bryntum",
7
+ "url": "https://bryntum.com",
8
+ "email": "info@bryntum.com"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://npm.bryntum.com/@bryntum/babel-preset-react-app.git"
13
+ },
14
+ "license": "MIT",
15
+ "bugs": {
16
+ "url": "https://github.com/facebook/create-react-app/issues"
17
+ },
18
+ "files": [
19
+ "readme-bryntum.md",
20
+ "create.js",
21
+ "dependencies.js",
22
+ "dev.js",
23
+ "index.js",
24
+ "webpack-overrides.js",
25
+ "prod.js",
26
+ "test.js"
27
+ ],
28
+ "dependencies": {
29
+ "@babel/core": "7.12.3",
30
+ "@babel/plugin-proposal-class-properties": "7.12.1",
31
+ "@babel/plugin-proposal-decorators": "7.12.1",
32
+ "@babel/plugin-proposal-nullish-coalescing-operator": "7.12.1",
33
+ "@babel/plugin-proposal-numeric-separator": "7.12.1",
34
+ "@babel/plugin-proposal-optional-chaining": "7.12.1",
35
+ "@babel/plugin-transform-flow-strip-types": "7.12.1",
36
+ "@babel/plugin-transform-react-display-name": "7.12.1",
37
+ "@babel/plugin-transform-runtime": "7.12.1",
38
+ "@babel/preset-env": "7.12.1",
39
+ "@babel/preset-react": "7.12.1",
40
+ "@babel/preset-typescript": "7.12.1",
41
+ "@babel/runtime": "7.12.1",
42
+ "babel-plugin-macros": "2.8.0",
43
+ "babel-plugin-transform-react-remove-prop-types": "0.4.24"
44
+ }
45
+ }
package/prod.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ const create = require('./create');
9
+
10
+ module.exports = function(api, opts) {
11
+ return create(api, Object.assign({ helpers : false }, opts), 'production');
12
+ };
package/test.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ const create = require('./create');
9
+
10
+ module.exports = function(api, opts) {
11
+ return create(api, Object.assign({ helpers : false }, opts), 'test');
12
+ };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ const crypto = require('crypto');
9
+
10
+ const macroCheck = new RegExp('[./]macro');
11
+
12
+ module.exports = function() {
13
+ return {
14
+ // This function transforms the Babel configuration on a per-file basis
15
+ config(config, { source }) {
16
+ // Babel Macros are notoriously hard to cache, so they shouldn't be
17
+ // https://github.com/babel/babel/issues/8497
18
+ // We naively detect macros using their package suffix and add a random token
19
+ // to the caller, a valid option accepted by Babel, to compose a one-time
20
+ // cacheIdentifier for the file. We cannot tune the loader options on a per
21
+ // file basis.
22
+ if (macroCheck.test(source)) {
23
+ return Object.assign({}, config.options, {
24
+ caller : Object.assign({}, config.options.caller, {
25
+ craInvalidationToken : crypto.randomBytes(32).toString('hex')
26
+ })
27
+ });
28
+ }
29
+ return config.options;
30
+ }
31
+ };
32
+ };