Closed Andision closed 1 year ago
Hello @Andision! I think the issue here is the usage of experimental appDir
, which is something not tested yet. Will look into it though.
Update: I believe there is a possible fix to introduce Next 13 App support, stay tuned for next release 😄
try config your project like this
// next.config.js
const nextConfig = {
reactStrictMode: true,
webpack: function (config, options) {
config.experiments = { asyncWebAssembly: true, syncWebAssembly: true };
return config;
},
}
module.exports = nextConfig
Facing the same issue when trying to deploy it to a Firebase Cloud Function. Is there any workarounds?
tried this in my webpack config but still getting same error
new LoaderOptionsPlugin({
test: /[\/\\]node_modules[\/\\]@dqbd[\/\\]tiktoken[\/\\]tiktoken_bg\.wasm$/,
options: {
// via https://github.com/dqbd/tiktoken/issues/28
asyncWebAssembly: true,
syncWebAssembly: true,
},
}),
I am using tiktoken with Next.js as below like code metioned in #23
Released a prerelease version, try npm install @dqbd/tiktoken@1.0.5-preview
, it should work with NextJS 13 with appDir without any further changes @Andision
Facing the same issue when trying to deploy it to a Firebase Cloud Function. Is there any workarounds?
Will look into it, haven't tested Firebase Cloud Functions yet, hopefully there will be a similar minor fix available. @natarius
Just tried a quick test via firebase init functions
and both firebase emulators:start --only functions
and firebase deploy --only functions
seem to work fine with @dqbd/tiktoken@^1.0.4
firebase/index.ts
import * as functions from "firebase-functions";
import { get_encoding } from "@dqbd/tiktoken";
export const helloWorld = functions.https.onRequest((request, response) => {
const enc = get_encoding("gpt2");
const result = new TextDecoder().decode(
enc.decode(enc.encode("hello world"))
);
enc.free();
functions.logger.info(result, { structuredData: true });
response.send(result);
});
firebase.json
{
"functions": [
{
"source": "functions",
"codebase": "default",
"runtime": "nodejs16",
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
],
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run build"
]
}
]
}
package.json
{
"name": "functions",
"scripts": {
"build": "tsc",
"build:watch": "tsc --watch",
"serve": "npm run build && firebase emulators:start --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"main": "lib/index.js",
"dependencies": {
"@dqbd/tiktoken": "^1.0.4",
"firebase-admin": "^11.5.0",
"firebase-functions": "^4.2.0"
},
"devDependencies": {
"firebase-functions-test": "^3.0.0",
"typescript": "^4.9.0"
},
"private": true
}
Would it be possible to share a reproducible repository? @natarius
Support for Next 13 appDir has landed in 1.0.6. Closing this issue for now (as it has been solved for Next 13).
@natarius If the issue persist on Firebase Functions, feel free to comment here or create a new issue with a reproducible example.
What webpack version do you use?
we are on v4...might that be the issue?
Support for Next 13 appDir has landed in 1.0.6. Closing this issue for now (as it has been solved for Next 13).
@natarius If the issue persist on Firebase Functions, feel free to comment here or create a new issue with a reproducible example.
I update my dependencies to "@dqbd/tiktoken": "^1.0.6",
in package.json
and this problem is solved. Thank you so much!
But I got another error🤣, I think I am supposed to report it in a new issue.
I am using tiktoken with Next.js as below like code metioned in #23
but I got error like this
I want to know how to fix this problem, thank you very much! Wish you a nice day!