Skip to content

Commit

Permalink
Use a single index.ts file to fix web imports
Browse files Browse the repository at this point in the history
When package.json main points to index.js it is always used regardless
of whether there is an index.web.js and config.resolve.extensions
prefers '.web.js' extensions because the extionsion is already specified
in the main field. A single index.js file re-exporting from either
RNSVG.js or RNSVG.web.js allows Webpack to intercept the extension
resolution correctly.
  • Loading branch information
marnusw authored and msand committed Sep 16, 2019
1 parent 467dd22 commit 2a26a1b
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 76 deletions.
77 changes: 77 additions & 0 deletions src/ReactNativeSVG.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import Shape from './elements/Shape';
import Rect, { RNSVGRect } from './elements/Rect';
import Circle, { RNSVGCircle } from './elements/Circle';
import Ellipse, { RNSVGEllipse } from './elements/Ellipse';
import Polygon from './elements/Polygon';
import Polyline from './elements/Polyline';
import Line, { RNSVGLine } from './elements/Line';
import Svg, { RNSVGSvg } from './elements/Svg';
import Path, { RNSVGPath } from './elements/Path';
import G, { RNSVGGroup } from './elements/G';
import Text, { RNSVGText } from './elements/Text';
import TSpan, { RNSVGTSpan } from './elements/TSpan';
import TextPath, { RNSVGTextPath } from './elements/TextPath';
import Use, { RNSVGUse } from './elements/Use';
import Image, { RNSVGImage } from './elements/Image';
import Symbol, { RNSVGSymbol } from './elements/Symbol';
import Defs, { RNSVGDefs } from './elements/Defs';
import LinearGradient, { RNSVGLinearGradient } from './elements/LinearGradient';
import RadialGradient, { RNSVGRadialGradient } from './elements/RadialGradient';
import Stop from './elements/Stop';
import ClipPath, { RNSVGClipPath } from './elements/ClipPath';
import Pattern, { RNSVGPattern } from './elements/Pattern';
import Mask, { RNSVGMask } from './elements/Mask';
import { parse, SvgAst, SvgFromUri, SvgFromXml, SvgUri, SvgXml } from './xml';

export {
Svg,
Circle,
Ellipse,
G,
Text,
TSpan,
TextPath,
Path,
Polygon,
Polyline,
Line,
Rect,
Use,
Image,
Symbol,
Defs,
LinearGradient,
RadialGradient,
Stop,
ClipPath,
Pattern,
Mask,
parse,
SvgAst,
SvgFromUri,
SvgFromXml,
SvgUri,
SvgXml,
Shape,
RNSVGMask,
RNSVGPattern,
RNSVGClipPath,
RNSVGRadialGradient,
RNSVGLinearGradient,
RNSVGDefs,
RNSVGSymbol,
RNSVGImage,
RNSVGUse,
RNSVGTextPath,
RNSVGTSpan,
RNSVGText,
RNSVGGroup,
RNSVGPath,
RNSVGLine,
RNSVGEllipse,
RNSVGCircle,
RNSVGRect,
RNSVGSvg,
};

export default Svg;
File renamed without changes.
78 changes: 2 additions & 76 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,77 +1,3 @@
import Shape from './elements/Shape';
import Rect, { RNSVGRect } from './elements/Rect';
import Circle, { RNSVGCircle } from './elements/Circle';
import Ellipse, { RNSVGEllipse } from './elements/Ellipse';
import Polygon from './elements/Polygon';
import Polyline from './elements/Polyline';
import Line, { RNSVGLine } from './elements/Line';
import Svg, { RNSVGSvg } from './elements/Svg';
import Path, { RNSVGPath } from './elements/Path';
import G, { RNSVGGroup } from './elements/G';
import Text, { RNSVGText } from './elements/Text';
import TSpan, { RNSVGTSpan } from './elements/TSpan';
import TextPath, { RNSVGTextPath } from './elements/TextPath';
import Use, { RNSVGUse } from './elements/Use';
import Image, { RNSVGImage } from './elements/Image';
import Symbol, { RNSVGSymbol } from './elements/Symbol';
import Defs, { RNSVGDefs } from './elements/Defs';
import LinearGradient, { RNSVGLinearGradient } from './elements/LinearGradient';
import RadialGradient, { RNSVGRadialGradient } from './elements/RadialGradient';
import Stop from './elements/Stop';
import ClipPath, { RNSVGClipPath } from './elements/ClipPath';
import Pattern, { RNSVGPattern } from './elements/Pattern';
import Mask, { RNSVGMask } from './elements/Mask';
import { parse, SvgAst, SvgFromUri, SvgFromXml, SvgUri, SvgXml } from './xml';
export * from './ReactNativeSVG';

export {
Svg,
Circle,
Ellipse,
G,
Text,
TSpan,
TextPath,
Path,
Polygon,
Polyline,
Line,
Rect,
Use,
Image,
Symbol,
Defs,
LinearGradient,
RadialGradient,
Stop,
ClipPath,
Pattern,
Mask,
parse,
SvgAst,
SvgFromUri,
SvgFromXml,
SvgUri,
SvgXml,
Shape,
RNSVGMask,
RNSVGPattern,
RNSVGClipPath,
RNSVGRadialGradient,
RNSVGLinearGradient,
RNSVGDefs,
RNSVGSymbol,
RNSVGImage,
RNSVGUse,
RNSVGTextPath,
RNSVGTSpan,
RNSVGText,
RNSVGGroup,
RNSVGPath,
RNSVGLine,
RNSVGEllipse,
RNSVGCircle,
RNSVGRect,
RNSVGSvg,
};

export default Svg;
export { default } from './ReactNativeSVG';

0 comments on commit 2a26a1b

Please sign in to comment.