Skip to content

Commit

Permalink
fix(v2): fix plugin-ideal-image breaking website (exports not defined)
Browse files Browse the repository at this point in the history
  • Loading branch information
endiliey committed Dec 1, 2019
1 parent 464d8e5 commit 005c684
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 42 deletions.

This file was deleted.

19 changes: 19 additions & 0 deletions packages/docusaurus-plugin-ideal-image/copyUntypedFiles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const path = require('path');
const fs = require('fs-extra');

/**
* Copy all untyped and static assets files to lib.
*/
const srcDir = path.resolve(__dirname, 'src');
const libDir = path.resolve(__dirname, 'lib');
fs.copySync(srcDir, libDir, {
filter(filepath) {
return !/__tests__/.test(filepath) && !/\.ts$/.test(filepath);
},
});
3 changes: 2 additions & 1 deletion packages/docusaurus-plugin-ideal-image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Docusaurus Plugin to generate an almost ideal image (responsive, lazy-loading, and low quality placeholder)",
"main": "lib/index.js",
"scripts": {
"tsc": "tsc"
"tsc": "tsc && node copyUntypedFiles.js"
},
"publishConfig": {
"access": "public"
Expand All @@ -17,6 +17,7 @@
"@endiliey/lqip-loader": "^3.0.2",
"@endiliey/react-ideal-image": "^0.0.11",
"@endiliey/responsive-loader": "^1.3.2",
"fs-extra": "^8.1.0",
"react-waypoint": "^9.0.2",
"sharp": "^0.22.1"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-plugin-ideal-image/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {Configuration} from 'webpack';

import path from 'path';

export = function(_context: LoadContext, options: PluginOptions) {
export default function(_context: LoadContext, options: PluginOptions) {
const isProd = process.env.NODE_ENV === 'production';
return {
name: 'docusaurus-plugin-ideal-image',
Expand Down Expand Up @@ -47,4 +47,4 @@ export = function(_context: LoadContext, options: PluginOptions) {
};
},
};
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';
import {ImageProps} from '../types';
import IdealImage from '@endiliey/react-ideal-image';

const Image: React.FC<ImageProps> = props => {
function Image(props) {
const {alt, className, img} = props;
return (
<IdealImage
Expand All @@ -20,12 +18,12 @@ const Image: React.FC<ImageProps> = props => {
width={img.src.width || 100}
placeholder={{lqip: img.preSrc}}
src={img.src.src}
srcSet={img.src.images.map((image: any) => ({
srcSet={img.src.images.map(image => ({
...image,
src: image.path,
}))}
/>
);
};
}

export default Image;
4 changes: 0 additions & 4 deletions packages/docusaurus-plugin-ideal-image/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,3 @@ export interface PluginOptions {
*/
quality?: number;
}

export interface ImageProps extends React.ImgHTMLAttributes<{}> {
img: any;
}
2 changes: 0 additions & 2 deletions packages/docusaurus-plugin-ideal-image/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@
"tsBuildInfoFile": "./lib/.tsbuildinfo",
"rootDir": "src",
"outDir": "lib",
"jsx": "react",
"typeRoots": ["@types"],
}
}

0 comments on commit 005c684

Please sign in to comment.