Issue building in vite for prod
See original GitHub issueHi,
Getting this issue when trying to build for prod, it works fine on dev envs. Sorry if this isn’t the right place for this issue. Let me know if not and I’ll open one elsewhere.
vite v2.6.14 building for production...
transforming...
warn - You have enabled the JIT engine which is currently in preview.
warn - Preview features are not covered by semver, may introduce breaking changes, and can change at any time.
✓ 545 modules transformed.
'createHmac' is not exported by __vite-browser-external, imported by node_modules/@algolia/client-search/dist/client-search.esm.js
file: /home/circleci/repo/buildchain/node_modules/@algolia/client-search/dist/client-search.esm.js:4:9
2: import { createTransporter, CallEnum, createMappedRequestOptions, serializeQueryParameters } from '@algolia/transporter';
3: import { MethodEnum } from '@algolia/requester-common';
4: import { createHmac } from 'crypto';
^
5:
6: function createBrowsablePromise(options) {
error during build:
Error: 'createHmac' is not exported by __vite-browser-external, imported by node_modules/@algolia/client-search/dist/client-search.esm.js
at error (/home/circleci/repo/buildchain/node_modules/rollup/dist/shared/rollup.js:158:30)
at Module.error (/home/circleci/repo/buildchain/node_modules/rollup/dist/shared/rollup.js:12354:16)
at Module.traceVariable (/home/circleci/repo/buildchain/node_modules/rollup/dist/shared/rollup.js:12739:29)
at ModuleScope.findVariable (/home/circleci/repo/buildchain/node_modules/rollup/dist/shared/rollup.js:11531:39)
at ReturnValueScope.findVariable (/home/circleci/repo/buildchain/node_modules/rollup/dist/shared/rollup.js:6902:38)
at ChildScope.findVariable (/home/circleci/repo/buildchain/node_modules/rollup/dist/shared/rollup.js:6902:38)
at ReturnValueScope.findVariable (/home/circleci/repo/buildchain/node_modules/rollup/dist/shared/rollup.js:6902:38)
at ChildScope.findVariable (/home/circleci/repo/buildchain/node_modules/rollup/dist/shared/rollup.js:6902:38)
at Identifier.bind (/home/circleci/repo/buildchain/node_modules/rollup/dist/shared/rollup.js:6392:40)
at CallExpression.bind (/home/circleci/repo/buildchain/node_modules/rollup/dist/shared/rollup.js:4998:23)
Some similar errors on other threads:
- aws-amplify/amplify-js#9639
- https://stackoverflow.com/questions/68991425/typeerror-amplify-configure-is-not-a-function-with-sveltekit-amplify-aws
I have tried the optimizeDeps trick on
algoliasearchandvue-instantsearchpackages with no luck here.
Contents of my package.json:
{
...
"dependencies": {
"algoliasearch": "^4.12.1",
"vue": "^3.2.9",
"vue-class-component": "^8.0.0-rc.1",
"vue-instantsearch": "^4.3.1",
"vuex": "^4.0.2",
"vuex-persistedstate": "^4.1.0"
},
"devDependencies": {
"@netlify/tailwindcss-first-line": "^1.0.1",
"@rollup/plugin-node-resolve": "^13.0.4",
"@tailwindcss/aspect-ratio": "^0.4.0",
"@tailwindcss/line-clamp": "^0.2",
"@typescript-eslint/eslint-plugin": "^4.32.0",
"@typescript-eslint/parser": "^4.32.0",
"@vitejs/plugin-legacy": "^1.5.2",
"@vitejs/plugin-vue": "^1.6.1",
"@vue/compiler-sfc": "^3.2.9",
"autoprefixer": "^10.3.4",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-airbnb-typescript": "^14.0.0",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-vue": "^7.18.0",
"postcss": "^8.3.6",
"rollup-plugin-critical": "^1.0.4",
"tailwindcss": "^2.2.11",
"tailwindcss-pseudo-elements": "^2.0.0",
"vite": "~2.6.14",
"vite-plugin-eslint": "^1.3.0",
"vite-plugin-restart": "0.0.2",
"vite-svg-loader": "^2.2.0",
"vite-tsconfig-paths": "^3.3.14"
},
...
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Building for Production - Vite
When it is time to deploy your app for production, simply run the vite build command. By default, it uses <root>/index.html as the...
Read more >Production build generates broken application #8777 - GitHub
Describe the bug When running the provided application in dev mode, it works as expected. However, when built for production and launched, ...
Read more >Vuejs3, Vite - How to run Production Build - Stack Overflow
According to the official docs, "vite build" will create the prod build using your index.html file as entry point.
Read more >Coding Shorts: Building with Vite - YouTube
I've been using Vue (via Vite ) with ASP.NET Core lately and I needed to build for testing and production. While I'd gotten...
Read more >Removing assertions from production build with Vite - Battlefy
This means it is safe to remove them from the production build. We are not relying on assertions for correctness, only to detect...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I googled the shit out of the
'createHmac' is not exported by __vite-browser-externaltype errors above so if there was ANY reference to that on a google search result on that especially on your site I deffo would have read it, I exhausted them all. As long as you dont noindex your FAQs then I would have found it.Otherwise, I have to admit it would be unlikely I would look there on the off chance as it seemed so niche I wouldn’t expect it.
I think if I would have seen it anywhere it would be around where you suggest the
esimport for vue3:Ah! Yeah that clears that up.
I think it might be helpful for others to reference that on pages such as: https://www.algolia.com/doc/guides/building-search-ui/installation/vue/?client=Vue+3
Which is probably going to ultimately need the browser version for rollup/vite users? Don’t think I’ve needed to do this with algolia with webpack before, though been a while!
Though appreciate maybe it’s just my very niche scenario that this occurs as I couldn’t reproduce.