tiny-trie
tiny-trie copied to clipboard
Adding tiny-trie package to React/ReactNative project causes multiple "Failed to parse source map" warnings.
Problem
Adding tiny-trie to a React or React Native project causes a bunch of warnings to be thrown when starting the project:
WARNING in ./node_modules/tiny-trie/lib/BinaryString.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from './node_modules/tiny-trie/src/BinaryString.ts' file: Error: ENOENT: no such file or directory, open './node_modules/tiny-trie/src/BinaryString.ts'
WARNING in ./node_modules/tiny-trie/lib/Trie.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from './node_modules/tiny-trie/src/Trie.ts' file: Error: ENOENT: no such file or directory, open './node_modules/tiny-trie/src/Trie.ts'
# and other, similar warnings...
Repro steps
I quickly spun up this repo that's set up to repro this issue. Just clone the repo and do: npm i && npm start. Alternatively, you can set up a new React project that triggers the issue by doing:
# 1. Create the project.
npx create-react-app repro
# 2. Navigate to the project's folder.
cd repro
# 3. Install the package.
npm install tiny-trie
# 4. Import a class from the `tiny-trie` package in any source file.
# ...
# 5. Start the project.
npm start
Here's a similar issue in some other project and it's corresponding fix.
Created PR #16 to circumvent this issue.