easy integration into node projects #4
Replies: 3 comments 4 replies
-
|
Wrapping this into an npm package is a great idea. The project's still in active development, so I haven't fully planned the packaging and update flow yet. If you're up for it, I'd love a pull request with the initial package setup (build config, entry points, versioning, and publish steps). I can review it and publish the package soon after. Appreciate the help! |
Beta Was this translation helpful? Give feedback.
-
|
@wiktor-jurek I have published an alpha on npm: https://www.npmjs.com/package/soaring-symbols Please let me know if you have any feedback on the API, catalog, or asset paths. I'm still refining how to handle mono vs. color for airlines that use a single‑color model. There may be adjustments as this settles, but I'll aim to keep changes minimal and clearly documented. |
Beta Was this translation helpful? Give feedback.
-
|
I tried to use
Steps to Reproduce
// app/api/airline-icon/route.ts
import { getAssets } from 'soaring-symbols';
export async function GET(request: NextRequest) {
const assets = getAssets('FR'); // Ryanair
// ... use assets
}
Expected BehaviorThe import should work seamlessly, allowing use of Actual BehaviorError 1: CommonJS require() in ESM contextError 2: During Next.js buildThe build fails because Root Cause Analysis
{
"main": "index.js",
"module": "index.js",
"exports": {
".": {
"types": "./index.d.ts",
"import": "./index.js" // ❌ Only ESM, no "require" field
},
"./assets/*": "./assets/*"
}
}
Current WorkaroundWe had to bypass the package's API and directly read the files: import { readFileSync } from 'fs';
import { join } from 'path';
// Read airlines.json directly instead of using getAssets()
const airlinesJsonPath = join(process.cwd(), 'node_modules', 'soaring-symbols', 'airlines.json');
const airlinesData = JSON.parse(readFileSync(airlinesJsonPath, 'utf-8'));
// Find airline manually
const airline = airlinesData.find(a =>
a.iata?.toUpperCase() === code ||
a.icao?.toUpperCase() === code
);
// Construct asset path manually
const assetPath = join(
process.cwd(),
'node_modules',
'soaring-symbols',
'assets',
airline.slug,
'icon.svg'
);
const svgContent = readFileSync(assetPath, 'utf-8');Use CaseWe're building a flight tracking app (StratusScribe) and want to display airline logos dynamically based on airline codes. The package's asset organization and data structure are perfect for our needs, but the module system issues prevent us from using it as intended. Thank you for maintaining this valuable resource! 🛫 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey team - love this initiative! I'm developing stratuscribe.com and this has been an awesome resource. Are you against me 'wrapping' this project into an npm package? Could I do that for easy updating?
Beta Was this translation helpful? Give feedback.
All reactions