Closed baptisteArno closed 3 years ago
Well, I'm doing this procedure with es-check
, not a runtime environment (since the problem happens on IE11 and I have a Mac). Is this different?
Here is the ES-Check output:
ES-Check: Going to check files using version 5
ES-Check: checking ./.next/static/b2DyBfmOskaUbPdLa78CL/_buildManifest.js
ES-Check: checking ./.next/static/b2DyBfmOskaUbPdLa78CL/_ssgManifest.js
ES-Check: checking ./.next/static/chunks/framework-64eb7138163e04c228e4.js
ES-Check: checking ./.next/static/chunks/main-655ad0ce567efa01caa9.js
ES-Check: checking ./.next/static/chunks/pages/_app-e3fe806f1e9b644b6907.js
ES-Check: failed to parse file: ./.next/static/chunks/pages/_app-e3fe806f1e9b644b6907.js
- error: SyntaxError: The keyword 'class' is reserved (1:16457)
ES-Check: checking ./.next/static/chunks/pages/_error-9faf4177fb4e528b4124.js
ES-Check: checking ./.next/static/chunks/pages/index-12657f910ba2a5bf6c82.js
ES-Check: checking ./.next/static/chunks/polyfills-a54b4f32bdc1ef890ddd.js
ES-Check: checking ./.next/static/chunks/webpack-61095c13c5984b221292.js
I'm sure it's firebase that does this because it's the only package I got
Still, you should do it because the problem most probably come from a dependency of firebase
and not firebase
itself.
- error: SyntaxError: The keyword 'class' is reserved (1:16457)
=> check 1:16457
to see the errorThank you for taking the time. I really appreciate it! Is there something else to disable for code uglification?
Here is my next config:
const withTM = require("next-transpile-modules")(["firebase"]);
module.exports = withTM({
reactStrictMode: true,
optimization: {
minimize: false,
},
});
It still produces minimized files
Maybe try with https://github.com/vercel/next.js/issues/7494 :)
Ok I had the wrong syntax. Here is the valid one:
const withTM = require("next-transpile-modules")(["firebase"]);
module.exports = withTM({
reactStrictMode: true,
webpack: (config) => {
config.optimization.minimize = false;
return config;
},
});
Thank you @martpie
The module I had to transpile were: @firebase/app
and @firebase/firestore
Hey, I'm currently on hour 15 here trying to figure out what is causing this issue. As a last ditch effort here. Do you guys have ANY idea where I could continue looking to solve this?
My jest.config.js is:
const nextJest = require("next/jest");
const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: "./",
});
// Add any custom config to be passed to Jest
const customJestConfig = {
// Add more setup options before each test is run
testEnvironment: "jest-environment-jsdom",
verbose: true,
// if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work
// moduleDirectories: ["node_modules", "<rootDir>/src/", "<rootDir>/test-utils"],
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
moduleNameMapper: {
"^@/(.*)$": "<rootDir>/src/$1",
},
testPathIgnorePatterns: ["/node_modules/", "/.next/"], // Don't test any next tests or tests in the modules
transformIgnorePatterns: ["<rootDir>/node_modules/"],
};
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
module.exports = createJestConfig(customJestConfig);
My next.config.js is:
const withTM = require("next-transpile-modules")(["firebase"]);
module.exports = withTM({
reactStrictMode: true,
webpack: (config) => {
config.optimization.minimize = false;
return config;
},
});
And my jest output runs all my tests until it hits my components that require my firebase.ts setup file...
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import { registerVersion } from '@firebase/app';
^^^^^^
SyntaxError: Cannot use import statement outside a module
> 1 | import { initializeApp } from "firebase/app";
| ^
2 | import { EmailAuthProvider, getAuth } from "firebase/auth";
3 | import { getFirestore } from "firebase/firestore";
Are you trying to transpile a local package or an npm package? npm package: firebase (v9.0.0-beta.2)
Describe the bug I'm using firebase package and it says
SyntaxError: The keyword 'let' is reserved
when check the es syntax usinges-check
package.I tried transpiling the package but it still compiles the code with reserved words
const
,let
,class
To Reproduce
yarn add firebase@9.0.0-beta.2 es-check
,firebase.ts
file with this:const firebaseProdConfig = {};
export const initFirebase = () => { if (getApps().length > 0) return; const firebaseApp = initializeApp(firebaseProdConfig); let firestoreSettings; if (typeof window !== "undefined") { firestoreSettings = { ignoreUndefinedProperties: true, }; } initializeFirestore(firebaseApp, firestoreSettings ?? {}); };
const withTM = require("next-transpile-modules")(["firebase"]);
module.exports = withTM({ reactStrictMode: true, });