TimboKZ / Chonky

😸 A File Browser component for React.
https://chonky.io
MIT License
744 stars 163 forks source link

Namespace '"C:/Users/..."' has no exported member 'FileHelper'. #44

Closed doanhuyc closed 3 years ago

doanhuyc commented 3 years ago

Hi,

After the 2.0.3 update, i always got this error

ERROR in [at-loader] ./node_modules/chonky/lib/action-definitions/index.d.ts:61:50 TS2694: Namespace '"C:/Users/.../node_modules/chonky/lib/index"' has no exported member 'FileHelper'.

Do you know why ?

TimboKZ commented 3 years ago

Hi, I will investigate this later today.

Meanwhile, can you use v2.0.2?

TimboKZ commented 3 years ago

I can't reproduce this error in a new Create React App project on Linux. Can you share some more details about your setup?

doanhuyc commented 3 years ago

I'm developing a Java app with React on front-end side. The OS is Windows. I used yarn add chonky to add your library to your app since 10 november. It worked pretty fine until yesterday (I don't know if it was related to the latest version or not)

TimboKZ commented 3 years ago

Couldn't reproduce this problem with yarn either. Can you try doing a clean install to see if it fixes the problem:

rm -rf node_modules/
rm -f yarn.lock package-lock.json

yarn install

If that doesn't work, can you share your package.json and potentially the project repo if it's public?

doanhuyc commented 3 years ago

hi, it still doesnt work after the re-install :(

here my package.json

{
    "name": "name",
    "version": "0.1.0",
    "description": "description",
    "repository": "repository",
    "license": "UNLICENSED",
    "private": true,
    "author": "Equisoft DCA",
    "maintainers": [],
    "contributors": [],
    "scripts": {
        "start": "yarn serve",
        "serve": "webpack-dev-server --config ./webpack/dev.config.js",
        "build": "webpack --config ./webpack/prod.config.js",
        "test": "jest --config=./jest.config.js",
        "test:ci": "jest --config=./jest.config.js --ci --runInBand",
        "lint": "tslint -p tsconfig.json src/**/*.{ts,tsx} && stylelint src/**/*.{ts,tsx}",
        "lint:ci": "yarn lint --formatters-dir node_modules/tslint-junit-formatter/formatters --format junit -o build/tests/tslint/junit.xml",
        "copy": "cpx public/**/*.* ../application/target/DCA/",
        "copy:verbose": "yarn copy -v",
        "build-for-maven-war": "yarn install && yarn lint && yarn test:ci && yarn build && yarn copy",
        "analyse": "webpack-bundle-analyzer public/stats.json"
    },
    "dependencies": {
        "@equisoft/design-elements-react": "~2.0.2",
        "@equisoft/design-elements-web": "~2.0.2",
        "axios": "^0.19.1",
        "chonky": "^2.0.3",
        "chonky-icon-fontawesome": "^2.0.3",
        "class-transformer": "^0.2.3",
        "date-fns": "^2.15.0",
        "dotenv": "^8.2.0",
        "dotenv-webpack": "^4.0.0",
        "equisoft-design-ui-elements": "^0.5.1",
        "i18next": "^19.8.2",
        "i18next-browser-languagedetector": "^5.0.0",
        "i18next-xhr-backend": "^3.2.2",
        "immer": "^7.0.5",
        "react": "~16.13.1",
        "react-contexify": "^4.1.1",
        "react-dom": "~16.13.1",
        "react-feather": "^2.0.4",
        "react-i18next": "^11.7.0",
        "react-router-dom": "^5.2.0",
        "react-sortable-tree": "^2.8.0",
        "react-sortable-tree-theme-file-explorer": "^2.0.0",
        "react-toastify": "^6.0.8",
        "react-tooltip": "^4.2.10",
        "reflect-metadata": "^0.1.13",
        "split.js": "^1.6.2",
        "styled-components": "^5.1.1"
    },
    "devDependencies": {
        "@equisoft/tslint-config": "~0.0.8",
        "@equisoft/tslint-config-react": "~0.0.3",
        "@svgr/webpack": "^5.4.0",
        "@testing-library/jest-dom": "^5.11.1",
        "@testing-library/react": "^10.4.7",
        "@types/jest": "~26.0.5",
        "@types/react": "~16.9.43",
        "@types/react-dom": "~16.9.8",
        "@types/react-router-dom": "^5.1.5",
        "@types/react-select": "^3.0.19",
        "@types/react-sortable-tree": "^0.3.12",
        "@types/react-sortable-tree-theme-file-explorer": "^0.0.0",
        "@types/styled-components": "^5.1.1",
        "@types/testing-library__jest-dom": "^5.9.1",
        "awesome-typescript-loader": "^5.2.1",
        "clean-webpack-plugin": "^3.0.0",
        "cpx": "^1.5.0",
        "css-loader": "^3.6.0",
        "file-loader": "^6.0.0",
        "html-webpack-plugin": "^4.3.0",
        "identity-obj-proxy": "^3.0.0",
        "jest": "~26.1.0",
        "jest-esm-transformer": "^1.0.0",
        "jest-styled-components": "^7.0.2",
        "node-sass": "^4.14.1",
        "prettier": "^2.0.5",
        "prettier-plugin-organize-imports": "^1.1.1",
        "sass-loader": "^9.0.2",
        "source-map-loader": "^1.0.1",
        "style-loader": "^1.2.1",
        "stylelint": "^13.6.1",
        "stylelint-config-recommended": "^3.0.0",
        "stylelint-config-styled-components": "^0.1.1",
        "stylelint-processor-styled-components": "^1.10.0",
        "svg-sprite-loader": "^5.0.0",
        "svgo": "^1.3.2",
        "svgo-loader": "^2.2.1",
        "ts-jest": "~26.1.3",
        "ts-mockito": "~2.6.1",
        "tslint": "~6.1.2",
        "tslint-config-prettier": "^1.18.0",
        "tslint-junit-formatter": "^5.1.0",
        "typescript": "^3.9.7",
        "typescript-plugin-styled-components": "^1.4.3",
        "webpack": "^4.43.0",
        "webpack-bundle-analyzer": "^3.8.0",
        "webpack-cli": "^3.3.12",
        "webpack-dev-server": "^3.11.0",
        "webpack-merge": "^5.0.9"
    },
    "resolutions": {
        "@types/react": "~16.9.43"
    }
}
TimboKZ commented 3 years ago

I think this has something to do with your custom webpack config. I'd ask you to share it, but I feel like it will be hard to reproduce locally even having your webpack config.

Could you perhaps share a minimal version of your repo with me? E.g. clone your repo, strip out all proprietary JS code and just leave a single page with Chonky?

TimboKZ commented 3 years ago

I just released v2.0.5 that fixes some potentially related issues. Can you try installing it?

yarn add chonky-icon-fontawesome@latest chonky@latest
doanhuyc commented 3 years ago

i still have the same error after update to 2.0.5 :(

doanhuyc commented 3 years ago

there are 3 files in my webpack folders and I barely know what are they doing exactly.. I'll share with you

common.config.js `const path = require('path'); const createStyledComponentsTransformer = require('typescript-plugin-styled-components').default;

const styledComponentsTransformer = createStyledComponentsTransformer(); const HtmlWebpackPlugin = require('html-webpack-plugin'); const { CleanWebpackPlugin } = require('clean-webpack-plugin');

const dotEnvPath = path.join(__dirname, '../', '.env'); require('dotenv').config({ path: dotEnvPath }); const Dotenv = require('dotenv-webpack');

module.exports = { entry: { main: './src/index.tsx', }, output: { filename: '[name].js', path: path.resolve(__dirname, '../public'), }, stats: { entrypoints: false, modules: false, // useless noise }, performance: { maxAssetSize: 3072000, maxEntrypointSize: 1024000, }, optimization: { moduleIds: 'hashed', runtimeChunk: 'single', splitChunks: { name: false, chunks: 'all', maxInitialRequests: Infinity, minSize: 0, cacheGroups: { react: { test: /[\/]node_modules\/[\/]/, name: 'react', }, 'api-core': { test: /[\/]src[\/]lib[\/]/, name: 'api-core', }, vendor: { test: /[\/]node_modules[\/]/, name: 'vendor', name(module) { // get the name. E.g. node_modules/packageName/not/this/part.js // or node_modules/packageName const packageName = module.context.match(/[\/]node_modules\/([\/]|$)/)[1];

                    // npm package names are URL-safe, but some servers don't like @ symbols
                    return `lib.${packageName.replace('@', '')}`;
                },
            },
        },
    },
},
module: {
    rules: [
        {
            test: /\.tsx?$/,
            loader: 'awesome-typescript-loader',
            options: {
                getCustomTransformers: () => ({ before: [styledComponentsTransformer] }),
            },
        },
        {
            enforce: 'pre',
            test: /\.js$/,
            loader: 'source-map-loader',
        },
        {
            test: /\.scss$/,
            use: ['style-loader', 'css-loader', 'sass-loader'],
        },
        {
            test: /\.css$/,
            use: ['style-loader', 'css-loader', 'sass-loader'],
        },
        {
            test: /.svg$/,
            loader: '@svgr/webpack',
            options: {
                svgoConfig: {
                    plugins: {
                        removeViewBox: false,
                    },
                },
            },
        },
        {
            test: /\.ttf$/,
            use: ['file-loader'],
        },
    ],
},
resolve: {
    extensions: ['.ts', '.tsx', '.js', '.jsx', '.scss'],
},
plugins: [
    new Dotenv({
        path: dotEnvPath,
        safe: false
    }),
    new HtmlWebpackPlugin({ template: './src/index.html' }),
    new CleanWebpackPlugin({ cleanOnceBeforeBuildPatterns: ['**/*.js'] }),
],

};`

dev.config.js `const { merge } = require('webpack-merge'); const common = require('./common.config');

module.exports = merge(common, { mode: 'development',

devtool: 'source-map',
output: { chunkFilename: '[name].js' },

devServer: {
    contentBase: './public',
    historyApiFallback: true,
    open: true,
    port: 3333,
},

});`

prod.config.js

`const { merge } = require('webpack-merge'); const common = require('./common.config');

const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

module.exports = merge(common, { mode: 'production', output: { filename: '[name].[contenthash].js' }, plugins: [new BundleAnalyzerPlugin({ generateStatsFile: true, analyzerMode: 'disabled' })], }); `

doanhuyc commented 3 years ago

i remember it worked pretty well on november 10 2020. Do you remember which version was it on this day ? I think i can use this version for a while

TimboKZ commented 3 years ago

That must have been the 2.0.0 release. Can you also try 2.0.1 to confirm that the issue was introduced between these 2 versions?

P.S. Thanks for more info about your project, will check it out later.

doanhuyc commented 3 years ago

Hey, i think ill use the 1.0.0 vesion for a while. Can you tell me what how to setChonkyDefault in the 1.0.0 version ?

TimboKZ commented 3 years ago

There's no such thing in v1, you have to set the props on each individual FileBrowser component.

doanhuyc commented 3 years ago

how to set iconComponent ? it seems there is no props for it in FileBrowser in v1

TimboKZ commented 3 years ago

That's correct, it's because you can't customise the icon component in v1 😁

So you're saying downgrading to 2.0.0 didn't help you at all?

doanhuyc commented 3 years ago

2.0.0 still has the same error ... :(

doanhuyc commented 3 years ago

its weird, i remember it was working pretty well last week .... but i cant remember which version was it.

doanhuyc commented 3 years ago

i found out the why it worked 1 week ago. The reason was, 1 week ago, i didnt have anything related to the ChonkyActions and ChonkyActionsData classes in my project. And after that, when I add new feature to handler actions, the error appears.

I'm trying to get rid all the import related to these classes but it seems i cant. The only way to retrieve data from action (E.g retrieve which folder was chosen by user) is from ChonkyActionsData ...

doanhuyc commented 3 years ago

By the way, what information about my project do you need me to provide ?

Any chance there is something that only work on linux but not windows in Chonky ? i'm asking it because i'm using windows