generated from Tahul/vue-composable-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add "types" to "exports" in package.json #23
Comments
Related to #25 |
For anyone that's getting bitten by this, until the maintainer can patch it up - I made this quick & dirty fix-it script. It's supposed to run as a post-install script in your project's // util/scripts/post-install-hooks/postInstall.cjs
const fs = require('fs');
const path = require('path');
const packageJsonPath = path.resolve(__dirname, '../../../node_modules', '@vueuse', 'gesture', 'package.json');
// Function to check if the required entry exists in package.json
function checkPackageJson() {
try {
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
if (packageJson.exports && packageJson.exports['.'] && packageJson.exports['.'].types === './dist/index.d.ts') {
console.log('Required entry already exists in package.json.');
return true;
}
} catch (error) {
console.error('Error reading package.json:', error);
return false;
}
return false;
}
// Function to update package.json with the required entry
function updatePackageJson() {
try {
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
if (!packageJson.exports) {
packageJson.exports = {};
}
if (!packageJson.exports['.']) {
packageJson.exports['.'] = {};
}
packageJson.exports['.'].types = './dist/index.d.ts';
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
console.log('package.json updated successfully.');
} catch (error) {
console.error('Error updating package.json:', error);
}
}
// Run the post-install script
if (!checkPackageJson()) {
updatePackageJson();
} In your ...
"postinstall": "node util/scripts/post-install-hooks/postInstall.cjs",
--- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
VS Code is complaining about a "wrong" configuration when using this package in a TypeScript project:
It can be easily fixed by adding a reference to the types to the
exports
section:The text was updated successfully, but these errors were encountered: