-
Notifications
You must be signed in to change notification settings - Fork 203
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
createClient breaks in production, but works in development mode (on same machine) #1936
Comments
I just found out that swcMinify (in next.config.json) is responsible for the error |
@johannsonic sorry to hear, but good you already found the cause! |
I've just updated from v9 to v10 and have also encountered this issue, where I cannot import anything from the contentful package, Specifically, between v10.1.3 (works) and v10.1.4 (breaks) - v10.1.3...v10.1.4 The config seems to be here contentful.js/webpack.config.js Lines 57 to 66 in 344c92f
I suspect the minified version might be being built differently or not exported correctly but can't quite pinpoint why or how, can we reopen @marcolink ? |
In the meantime, I'm using a pnpm patch to go back to how it was, to get around the issue in my builds diff --git a/package.json b/package.json
index 3a16b52ac0965ca27f25ed9fac2363487ba5aad3..15c2c04544b95a6d23d04ae20ae6f6e2e45aced4 100644
--- a/package.json
+++ b/package.json
@@ -3,8 +3,8 @@
"description": "Client for Contentful's Content Delivery API",
"version": "10.6.16",
"homepage": "https://www.contentful.com/developers/documentation/content-delivery-api/",
- "main": "./dist/contentful.node.min.js",
- "browser": "./dist/contentful.browser.min.js",
+ "main": "./dist/contentful.node.js",
+ "browser": "./dist/contentful.browser.js",
"types": "./dist/types/index.d.ts",
"browserslist": [
">0.3%",
|
I noticed that the cloned the repo, installed packages, did a build and adjusted the build script to also check the minified file "postbuild": "npm run check:browser && npm run check:browser:min && npm run check:node && npm run test:demo-projects",
"check:browser": "es-check es2017 --module ./dist/contentful.browser.js",
"check:browser:min": "es-check es2017 --module ./dist/contentful.browser.min.js", // i added this command Sure enough it succeeds for the standard file, but fails for the minified file > contentful@0.0.0-determined-by-semantic-release postbuild
> npm run check:browser && npm run check:browser:min && npm run check:node && npm run test:demo-projects
> contentful@0.0.0-determined-by-semantic-release check:browser
> es-check es2017 --module ./dist/contentful.browser.js
info: ES-Check: there were no ES version matching errors! 🎉
> contentful@0.0.0-determined-by-semantic-release check:browser:min
> es-check es2017 --module ./dist/contentful.browser.min.js
error: ES-Check: there were 1 ES version matching errors.
info:
ES-Check Error:
----
· erroring file: ./dist/contentful.browser.min.js
· error: SyntaxError: Unexpected token (1:50841)
· see the printed err.stack below for context
----
SyntaxError: Unexpected token (1:50841) |
added a failing scenario #2130 |
Can confirm this is no longer an issue in 10.9.0+ thanks a bundle+ 😄 |
Expected Behavior
The contentful client should be created with the createClient method provided by the library.
Actual Behavior
The createClient function works in DEV mode but breaks in PROD mode (both on local machine).
The error says 'r is not a function'
Steps to Reproduce
Use the createClient function in PROD mode (npm run built && npm run start in nextjs)
Environment
Next.JS 12.3.0
React 18.2.0
I load the library only on the client (using a dynamic() call from the nextjs package.
The text was updated successfully, but these errors were encountered: