react-datetimerange-picker
react-datetimerange-picker copied to clipboard
[!] Error: 'default' is not exported by node_modules/@wojtekmaj/react-datetimerange-picker/dist/entry.js, imported by src/FormikDateTimeRangeField.tsx
Hello,
I have a project in which I am using @wojtekmaj/react-datetimerange-picker. Running tsc on the project does not give me any error but when I try to build using rollup I get this error:
[!] Error: 'default' is not exported by node_modules/@wojtekmaj/react-datetimerange-picker/dist/entry.js, imported by src/FormikDateTimeRangeField.tsx
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
src/FormikDateTimeRangeField.tsx (4:7)
...
4: import DateTimeRangePicker from "@wojtekmaj/react-datetimerange-picker"; // 113 kB
I have checked node_modules/@wojtekmaj/react-datetimerange-picker/dist/entry.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
require("react-calendar/dist/Calendar.css");
require("react-clock/dist/Clock.css");
var _DateTimeRangePicker = _interopRequireDefault(require("./DateTimeRangePicker"));
require("./DateTimeRangePicker.css");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// File is created during build phase and placed in dist directory
// eslint-disable-next-line import/no-unresolved
var _default = _DateTimeRangePicker["default"];
My rollup.config.js is like this:
export default {
input: "src/index.ts",
output: [
{
file: pkg.module,
format: "es", // https://www.rollupjs.org/guide/en/#outputformat
exports: "named", // https://www.rollupjs.org/guide/en/#outputexports
sourcemap: true
},
{
file: pkg.main,
format: "commonjs", // https://www.rollupjs.org/guide/en/#outputformat
exports: "named", // https://www.rollupjs.org/guide/en/#outputexports
sourcemap: true
}
],
plugins: [
external(),
resolve(), // A Rollup plugin which locates modules using the Node resolution algorithm, for using third party modules in node_modules
typescript(), // The plugin loads any compilerOptions from the tsconfig.json file by default. Passing options to the plugin directly overrides those options
json(),
terser(),
babel({
babelHelpers: 'bundled',
include: "./src/**/*.js", // A minimatch pattern, or array of patterns, which specifies the files in the build the plugin should operate on.
presets: ['@babel/env', '@babel/preset-react'] // https://stackoverflow.com/a/52885295/147530
})
]
};
I am really not an expert in these JavaScript tools. Can anyone help me out here? thanks
https://github.com/microsoft/TypeScript/issues/32005
the error is there even if I edit entry.js and change to:
exports.default = _default;
on last line. I am puzzled why does tsc work but the rollup typescript plugin does not? I tried both @rollup/plugin-typescript as well as rollup-plugin-typescript2
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.
This should no longer be an issue, but please let me know if it is.