File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // @remove -file-on-eject
2+ /**
3+ * Copyright (c) 2014-present, Facebook, Inc.
4+ *
5+ * This source code is licensed under the MIT license found in the
6+ * LICENSE file in the root directory of this source tree.
7+ */
8+ 'use strict' ;
9+
10+ const babelJest = require ( 'babel-jest' ) ;
11+
12+ module . exports = babelJest . createTransformer ( {
13+ presets : [ require . resolve ( 'babel-preset-react-app' ) ] ,
14+ babelrc : false ,
15+ configFile : false ,
16+ } ) ;
Original file line number Diff line number Diff line change 1+ // @remove -on-eject-begin
2+ /**
3+ * Copyright (c) 2014-present, Facebook, Inc.
4+ *
5+ * This source code is licensed under the MIT license found in the
6+ * LICENSE file in the root directory of this source tree.
7+ */
8+ // @remove -on-eject-end
9+ 'use strict' ;
10+
11+ // This is a custom Jest transformer turning style imports into empty objects.
12+ // http://facebook.github.io/jest/docs/en/webpack.html
13+
14+ module . exports = {
15+ process ( ) {
16+ return 'module.exports = {};' ;
17+ } ,
18+ getCacheKey ( ) {
19+ // The output is always the same.
20+ return 'cssTransform' ;
21+ } ,
22+ } ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const path = require ( 'path' ) ;
4+ const camelcase = require ( 'camelcase' ) ;
5+
6+ // This is a custom Jest transformer turning file imports into filenames.
7+ // http://facebook.github.io/jest/docs/en/webpack.html
8+
9+ module . exports = {
10+ process ( src , filename ) {
11+ const assetFilename = JSON . stringify ( path . basename ( filename ) ) ;
12+
13+ if ( filename . match ( / \. s v g $ / ) ) {
14+ // Based on how SVGR generates a component name:
15+ // https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6
16+ const pascalCaseFilename = camelcase ( path . parse ( filename ) . name , {
17+ pascalCase : true ,
18+ } ) ;
19+ const componentName = `Svg${ pascalCaseFilename } ` ;
20+ return `const React = require('react');
21+ module.exports = {
22+ __esModule: true,
23+ default: ${ assetFilename } ,
24+ ReactComponent: React.forwardRef(function ${ componentName } (props, ref) {
25+ return {
26+ $$typeof: Symbol.for('react.element'),
27+ type: 'svg',
28+ ref: ref,
29+ key: null,
30+ props: Object.assign({}, props, {
31+ children: ${ assetFilename }
32+ })
33+ };
34+ }),
35+ };` ;
36+ }
37+
38+ return `module.exports = ${ assetFilename } ;` ;
39+ } ,
40+ } ;
Original file line number Diff line number Diff line change @@ -42,7 +42,9 @@ declare module '*.webp' {
4242declare module '*.svg' {
4343 import * as React from 'react' ;
4444
45- export const ReactComponent : React . FunctionComponent < React . SVGProps < SVGSVGElement > > ;
45+ export const ReactComponent : React . FunctionComponent < React . SVGProps <
46+ SVGSVGElement
47+ > & { title ?: string } > ;
4648
4749 const src : string ;
4850 export default src ;
Original file line number Diff line number Diff line change 1+ This file has moved [ here] ( https://github.com/devloco/create-react-wptheme/blob/master/packages/cra-template-wptheme-typescript/README.md )
Original file line number Diff line number Diff line change 1+ This file has moved [ here] ( https://github.com/devloco/create-react-wptheme/blob/master/packages/cra-template-wptheme/README.md )
You can’t perform that action at this time.
0 commit comments