Javascript Firebase/auth导入源地图警告
我正在使用firebase library v7.15.5构建react应用程序,当我导入“firebase/auth”时,它工作正常,但会在终端中向我发出警告:Javascript Firebase/auth导入源地图警告,javascript,firebase,import,warnings,source-maps,Javascript,Firebase,Import,Warnings,Source Maps,我正在使用firebase library v7.15.5构建react应用程序,当我导入“firebase/auth”时,它工作正常,但会在终端中向我发出警告: WARNING in ./node_modules/@firebase/auth/dist/auth.esm.js Module Warning (from ./node_modules/source-map-loader/dist/cjs.js): Failed to parse source map from 'D:\Projec
WARNING in ./node_modules/@firebase/auth/dist/auth.esm.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'D:\Projects\DeparturesSchedule\node_modules\@firebase\auth\dist\ [synthetic:es6\promise\promise] ' file: Error: ENOENT: no such file or directory, open 'D:\Projects\DeparturesSchedule\node_modules\@firebase\auth\dist\ [synthetic:es6\promise\promise] '
@ ./node_modules/firebase/auth/dist/index.esm.js 1:0-24
@ ./src/utils/firebase/firebase.ts
@ ./src/store/actions/appProps/index.ts
@ ./src/pages/schedule/index.tsx
@ ./src/components/app/index.tsx
@ ./src/index.tsx
@ multi ./src/index.tsx
WARNING in ./node_modules/@firebase/auth/dist/auth.esm.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'D:\Projects\DeparturesSchedule\node_modules\@firebase\auth\dist\ [synthetic:es6\util\arrayiterator] ' file: Error: ENOENT: no such file or directory, open 'D:\Projects\DeparturesSchedule\node_modules\@firebase\auth\dist\ [synthetic:es6\util\arrayiterator] '
@ ./node_modules/firebase/auth/dist/index.esm.js 1:0-24
@ ./src/utils/firebase/firebase.ts
@ ./src/store/actions/appProps/index.ts
@ ./src/pages/schedule/index.tsx
@ ./src/components/app/index.tsx
@ ./src/index.tsx
@ multi ./src/index.tsx
WARNING in ./node_modules/@firebase/auth/dist/auth.esm.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'D:\Projects\DeparturesSchedule\node_modules\@firebase\auth\dist\ [synthetic:es6\util\makeiterator] ' file: Error: ENOENT: no such file or directory, open 'D:\Projects\DeparturesSchedule\node_modules\@firebase\auth\dist\ [synthetic:es6\util\makeiterator] '
@ ./node_modules/firebase/auth/dist/index.esm.js 1:0-24
@ ./src/utils/firebase/firebase.ts
@ ./src/store/actions/appProps/index.ts
@ ./src/pages/schedule/index.tsx
@ ./src/components/app/index.tsx
@ ./src/index.tsx
@ multi ./src/index.tsx
WARNING in ./node_modules/@firebase/auth/dist/auth.esm.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'D:\Projects\DeparturesSchedule\node_modules\@firebase\auth\dist\ [synthetic:util\defineproperty] ' file: Error: ENOENT: no such file or directory, open 'D:\Projects\DeparturesSchedule\node_modules\@firebase\auth\dist\ [synthetic:util\defineproperty] '
@ ./node_modules/firebase/auth/dist/index.esm.js 1:0-24
@ ./src/utils/firebase/firebase.ts
@ ./src/store/actions/appProps/index.ts
@ ./src/pages/schedule/index.tsx
@ ./src/components/app/index.tsx
@ ./src/index.tsx
@ multi ./src/index.tsx
WARNING in ./node_modules/@firebase/auth/dist/auth.esm.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'D:\Projects\DeparturesSchedule\node_modules\@firebase\auth\dist\ [synthetic:util\global] ' file: Error: ENOENT: no such file or directory, open 'D:\Projects\DeparturesSchedule\node_modules\@firebase\auth\dist\ [synthetic:util\global] '
@ ./node_modules/firebase/auth/dist/index.esm.js 1:0-24
@ ./src/utils/firebase/firebase.ts
@ ./src/store/actions/appProps/index.ts
@ ./src/pages/schedule/index.tsx
@ ./src/components/app/index.tsx
@ ./src/index.tsx
@ multi ./src/index.tsx
WARNING in ./node_modules/@firebase/auth/dist/auth.esm.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'D:\Projects\DeparturesSchedule\node_modules\@firebase\auth\dist\ [synthetic:util\polyfill] ' file: Error: ENOENT: no such file or directory, open 'D:\Projects\DeparturesSchedule\node_modules\@firebase\auth\dist\ [synthetic:util\polyfill] '
@ ./node_modules/firebase/auth/dist/index.esm.js 1:0-24
@ ./src/utils/firebase/firebase.ts
@ ./src/store/actions/appProps/index.ts
@ ./src/pages/schedule/index.tsx
@ ./src/components/app/index.tsx
@ ./src/index.tsx
@ multi ./src/index.tsx
Child html-webpack-plugin for "index.html":
1 asset
Entrypoint undefined = index.html
4 modules
i 「wdm」: Compiled with warnings.
这是文件的代码,我在其中初始化firebase模块:
import app from 'firebase/app';
import 'firebase/database';
import 'firebase/auth';
const config = {
apiKey: process.env.API_KEY,
authDomain: process.env.AUTH_DOMAIN,
databaseURL: process.env.DB_URL,
storageBucket: process.env.STORAGE_BUCKET,
};
app.initializeApp(config);
const database = app.database();
const auth = app.auth();
export { database, auth };
尝试删除节点_模块并重新安装所有模块,但无法解决问题。也许我应该以不同的方式导入它,或者配置webpack或tsconfig?我不知道
感谢您的帮助。通过从webpack.config中删除这些代码行解决了此问题
{
enforce: "pre",
test: /\.js$/,
loader: "source-map-loader"
},
如果您绝对需要源映射(我认为您并不是真的需要,因为您的解决方案是禁用它们),那么您可以添加一个for firebase(或者只是firebase/auth)。示例(自行构建):
注意:只使用上面的排除规则之一那么,你刚刚禁用了源地图加载器?@Werlious是的,我想可能有另一种方法可以解决这个问题,但它对我有效
{
enforce: "pre",
test: /\.js$/,
loader: "source-map-loader",
exclude: /node_modules\/@firebase/ //to exclude firebase from source-map
exclude: /node_modules\/@firebase\/auth/ //to just exclude firebase auth from source-map
},