Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import not working #25

Open
Azmisov opened this issue Jul 21, 2023 · 2 comments
Open

Import not working #25

Azmisov opened this issue Jul 21, 2023 · 2 comments

Comments

@Azmisov
Copy link

Azmisov commented Jul 21, 2023

The imports in your example will not work, e.g.

import {parse} from "cache-control-parser";

gives error: SyntaxError: Named export 'parse' not found. The requested module 'cache-control-parser' is a CommonJS module, which may not support all module.exports as named exports.

The following will work though:

import CacheControl from "cache-control-parser";
CacheControl.parse
@shift-yuta-katayama
Copy link

I am able to import parse on my end with no problem.
Specifically, the following implementation did not cause any errors.

import routeCache from 'route-cache';
import { parse } from 'cache-control-parser';
...

export default (cacheSeconds) => {
	return routeCache.cacheSeconds(cacheSeconds, (req) => {
		const cacheControl = req.headers['cache-control'];
		const directives = cacheControl ? parse(cacheControl) : {};
		if (directives['no-cache']) return false;

		return ...
	});
};

Repository owner deleted a comment from Soumya6Tiwari Feb 23, 2024
Repository owner deleted a comment from roneyfraga Mar 18, 2024
@predaytor
Copy link

I think the package should be published as ESM-only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@Azmisov @predaytor @shift-yuta-katayama and others