Comments (4)
I did a bit more testing today and everything seems fine from what I can tell.
I made a simple project to depend on country-coder like this:
package.json
{
"name": "test",
"version": "0.0.0",
"license": "ISC",
"type": "module",
"dependencies": {
"@ideditor/country-coder": "5.0.2"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
}
}
test.cjs
const countryCoder = require('@ideditor/country-coder');
const result = countryCoder.iso1A2Code('Q145');
console.log(result);
test.mjs
import * as countryCoder from '@ideditor/country-coder';
const result = countryCoder.iso1A2Code('Q145');
console.log(result);
both imports work:
~/Projects/test % node --version
v12.22.1
~/Projects/test % node test.cjs
GB
~/Projects/test % node test.mjs
GB
My guess is that whatever tool you used bundle your react app is using the iife "browser" build instead of the "main" or "module" exports. (webpack and esbuild are common culprits here).
Can you check if this is the problem (edit node_modules/@ideditor/country-coder/package.json
and remove the 2 lines like "browser": "./dist/country-coder.iife.js",
and see if things start working again)
I'll probably just remove the "browser" export. Some guides say to add it, but I dont know why.
from country-coder.
Thanks for reporting - can you double check that you are definitely using v5.0.2 (sometimes a package-lock or yarn.lock file will lock in an older non-working dependency)
I have v5.0.1 working over in the sister project https://github.com/ideditor/location-conflation , will test it with v5.0.2 tomorrow. It's very possible that the export map has a problem.
from country-coder.
Thanks. I am definitely using v5.0.2, just double checked.
The specific error is (the result of calling the function iso1A2Code twice, or any function that is imported)
WARN 0 [TypeError: undefined is not a function]
WARN 1 [TypeError: undefined is not a function]
Error: EISDIR: illegal operation on a directory, read
at Object.readSync (fs.js:523:3)
at tryReadSync (fs.js:348:20)
at Object.readFileSync (fs.js:385:19)
at UnableToResolveError.buildCodeFrameMessage
"react": "^17.0.2",
"react-native": "^0.64.2",
from country-coder.
@bhousel Thank you very much for the help. Just one small thing left before package is fully ready for RN again.
Yes browser export was causing issues, and I get the actual root issue now aside from browser export.
It's the file extension pattern matching.
This is v4.1.0 package.json, it conforms to pattern
"main": "./dist/country-coder.js",
"module": "./dist/country-coder.module.js",
it conforms to this pattern that React-Native wants, notice the .js extension (.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.svg|.native.svg|.svg)
, without this Xcode will not build.
However in v5.0.3, it becomes
"main": "./dist/country-coder.cjs",
"module": "./dist/country-coder.mjs",
If I just added a .js to both of these files (RN uses module but both pattern matching was needed)
"main": "./dist/country-coder.cjs.js",
"module": "./dist/country-coder.mjs.js",
This works perfectly. All features are now back online. It's silly, but the pattern matching is strict.
from country-coder.
Related Issues (20)
- Reduce package/bundle size - dynamically import borders.json HOT 1
- FeedBack - Code HOT 1
- Northen Cyprus' ISO code HOT 2
- ISO 3166 of countries with Sovereign states HOT 1
- TW polygon missing Lienchiang County and parts of Kinmen County (Wuqiu) HOT 1
- Get rid of prettier
- ISO 639 Language Codes HOT 6
- Types not added in package.json exports HOT 1
- I suggest changing the source also to my repo where I keep the updated list from iso.org HOT 2
- Support bbox query? HOT 2
- [wrong repo]
- Sub-regions, repeated data and .geojson hosting HOT 1
- United Kingdom HOT 12
- We might be using "exports" wrong HOT 2
- File extension pattern matching in React Native 0.62.4 for mjs cjs main and module files HOT 4
- France: EU + Europe missing ? HOT 3
- Fully ESM compatible ?
- Don't use for..in to iterate over arrays
- Missing triangle on Swiss border HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from country-coder.