-
Notifications
You must be signed in to change notification settings - Fork 12
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
Failed to minify code in create-react-app project #56
Comments
Have you tried importing the source of the driver, not the dist files? create-react-app does its own babel transpilation, but not on files imported from |
I'm assuming this is the responsibility of the imported package? Maybe we should rework the build settings? |
To answer my own suggestion: importing from source doesn't work either. When importing directly from the source folder in a import Orm from 'bigchaindb-orm/src' A new warning comes up upon build, now complaining about the same thing but for > react-scripts build
Creating an optimized production build...
Failed to compile.
Failed to minify the code from this file:
./node_modules/bigchaindb-driver/dist/browser/bigchaindb-driver.cjs2.min.js:25:24726 |
create-react-app
project
create-react-app
project
For reference, we solved this temporarily by copying the respective files into the CRA src directory before build, passing them to CRA's own transpilation. That's a workaround until either:
Here's the script: #!/usr/bin/env bash
set -e
cp -R ./node_modules/bigchaindb-driver/dist/node/ ./src/lib/bigchaindb-driver
cp -R ./node_modules/bigchaindb-orm/src/ ./src/lib/bigchaindb-orm
cp -R ./node_modules/decamelize/ ./src/lib/decamelize
replaceStrings () {
# remove 'use strict'; from all js files
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i "" "s|'use strict';||g" "$1"
else
sed -i "s|'use strict';||g" "$1"
fi
# replace require/import calls with local versions
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i "" "s|'bigchaindb-driver'|'../bigchaindb-driver'|g" "$1"
sed -i "" "s|'decamelize'|'../decamelize'|g" "$1"
else
sed -i "s|'bigchaindb-driver'|'../bigchaindb-driver'|g" "$1"
sed -i "s|'decamelize'|'../decamelize'|g" "$1"
fi
}
for i in ./src/lib/**/*.js; do
replaceStrings "$i"
done
for i in ./src/lib/**/**/*.js; do
replaceStrings "$i"
done
printf '\n👍 Successfully copied BigchainDB drivers. Hooray!\n\n See why we are doing this:\n https://github.com/bigchaindb/js-driver-orm/issues/56\n' |
Update react-scripts to at least, bug will be fixed with new react release: |
The text was updated successfully, but these errors were encountered: