Skip to content

Commit

Permalink
Better ESM imports
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanoverna committed Jun 28, 2023
1 parent e53a6fb commit adc3d20
Show file tree
Hide file tree
Showing 17 changed files with 613 additions and 625 deletions.
1,127 changes: 567 additions & 560 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
"js"
],
"transform": {
"\\.(ts|tsx)$": "ts-jest"
"\\.(ts|tsx)$": ["ts-jest", { "useESM": true }]
},
"setupFiles": [
"raf/polyfill"
Expand All @@ -133,7 +133,10 @@
],
"snapshotSerializers": [
"enzyme-to-json/serializer"
]
],
"moduleNameMapper": {
"^(\\.\\.?\\/.+)\\.js$": "$1"
}
},
"dependencies": {
"datocms-listen": "^0.1.9",
Expand Down
35 changes: 0 additions & 35 deletions rollup.config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/Image/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { mount } from 'enzyme';
import 'intersection-observer';
import { Image } from '../index';
import { Image } from '../index.js';
import { mockAllIsIntersecting } from 'react-intersection-observer/test-utils';

const data = {
Expand Down
10 changes: 5 additions & 5 deletions src/Image/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, {
useEffect,
version,
} from 'react';
import { useInView } from './useInView';
import { useInView } from './useInView.js';
import { encode } from 'universal-base64';

const isSsr = typeof window === 'undefined';
Expand Down Expand Up @@ -375,10 +375,10 @@ export const Image = forwardRef<HTMLDivElement, ImagePropTypes>(
...(layout === 'fill'
? absolutePositioning
: layout === 'intrinsic'
? { position: 'relative', width: '100%', maxWidth: width }
: layout === 'fixed'
? { position: 'relative', width }
: { position: 'relative', width: '100%' }),
? { position: 'relative', width: '100%', maxWidth: width }
: layout === 'fixed'
? { position: 'relative', width }
: { position: 'relative', width: '100%' }),
...style,
}}
>
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/Seo/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
renderMetaTagsToString,
toNextMetadata,
toRemixMeta,
} from '..';
import { TitleMetaLinkTag } from '../types';
} from '../index.js';
import { TitleMetaLinkTag } from '../types.js';

const metaTags: TitleMetaLinkTag[] = [
{
Expand Down
10 changes: 5 additions & 5 deletions src/Seo/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './types';
export * from './remixUtils';
export * from './nextUtils';
export * from './renderMetaTags';
export * from './renderMetaTagsToString';
export * from './types.js';
export * from './remixUtils.js';
export * from './nextUtils.js';
export * from './renderMetaTags.js';
export * from './renderMetaTagsToString.js';
2 changes: 1 addition & 1 deletion src/Seo/nextUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
isSeoLinkTag,
isSeoMetaTag,
isSeoOrFaviconTag,
} from './types';
} from './types.js';

export type AppleIcon = {
sizes: string;
Expand Down
2 changes: 1 addition & 1 deletion src/Seo/remixUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TitleMetaLinkTag, SeoOrFaviconTag } from './types';
import { TitleMetaLinkTag, SeoOrFaviconTag } from './types.js';

interface RemixHtmlMetaDescriptor {
[name: string]: string | string[];
Expand Down
2 changes: 1 addition & 1 deletion src/Seo/renderMetaTags.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { TitleMetaLinkTag, SeoOrFaviconTag } from './types';
import { TitleMetaLinkTag, SeoOrFaviconTag } from './types.js';

export function renderMetaTags(
data: TitleMetaLinkTag[] | SeoOrFaviconTag[],
Expand Down
2 changes: 1 addition & 1 deletion src/Seo/renderMetaTagsToString.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TitleMetaLinkTag, SeoOrFaviconTag } from './types';
import { TitleMetaLinkTag, SeoOrFaviconTag } from './types.js';

export function renderMetaTagsToString(
data: TitleMetaLinkTag[] | SeoOrFaviconTag[],
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/StructuredText/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
StructuredTextDocument,
RenderError,
renderNodeRule,
} from '../index';
} from '../index.js';
import { isHeading } from 'datocms-structured-text-utils';
import { renderMarkRule } from 'datocms-structured-text-generic-html-renderer';

Expand Down
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './Image';
export * from './Seo';
export * from './useQuerySubscription';
export * from './StructuredText';
export * from './useSiteSearch';
export * from './Image/index.js';
export * from './Seo/index.js';
export * from './useQuerySubscription/index.js';
export * from './StructuredText/index.js';
export * from './useSiteSearch/index.js';
3 changes: 2 additions & 1 deletion tsconfig.esnext.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"outDir": "./dist/esm",
"declarationDir": "./dist/esm",
"isolatedModules": true,
"moduleResolution": "NodeNext"
},
}
}
20 changes: 16 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,29 @@
"declarationDir": "./dist/types",
"module": "commonjs",
"noImplicitAny": true,
"lib": ["es2017", "es7", "es6", "dom"],
"lib": [
"es2017",
"es7",
"es6",
"dom"
],
"outDir": "./dist/cjs",
"target": "es3",
"moduleResolution": "node",
"moduleResolution": "NodeNext",
"jsx": "react",
"resolveJsonModule": true,
"strictNullChecks": true,
"esModuleInterop": true,
"skipLibCheck": false,
"sourceMap": true
},
"include": ["src/**/*", "test/jest-dom.d.ts", "react-extras.d.ts"],
"exclude": ["node_modules", "dist"]
"include": [
"src/**/*",
"test/jest-dom.d.ts",
"react-extras.d.ts"
],
"exclude": [
"node_modules",
"dist"
]
}

0 comments on commit adc3d20

Please sign in to comment.