javascript - NodeJS ile Babel spread operatörü çalışmıyor
Babel (7.5.0) ve NodeJS son sürümünü (12.x) kullanıyorum, bu yüzden spread operatörü zaten NodeJS tarafından işleniyor ve babel'in onunla oynamasını istemiyorum.
Bu benim .babelrc dosyam :
{
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-runtime"
],
"presets": [
[
"@babel/preset-env",
{
"modules": "commonjs",
"targets": {
"node": "current"
},
"useBuiltIns": "usage"
}
]
]
}
Bu benim hatam :
ERROR in ./src/utils/logger/logger.js
Module build failed: ReferenceError: Unknown helper objectSpread2
at loadHelper (/app/node_modules/@babel/helpers/lib/index.js:238:27)
at Object.getDependencies (/app/node_modules/@babel/helpers/lib/index.js:279:21)
at File.addHelper (/app/node_modules/@babel/core/lib/transformation/file/file.js:204:33)
at PluginPass.addHelper (/app/node_modules/@babel/core/lib/transformation/plugin-pass.js:31:22)
at PluginPass.ObjectExpression (/app/node_modules/@babel/plugin-proposal-object-rest-spread/lib/index.js:379:25)
at newFn (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/visitors.js:193:21)
at NodePath._call (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:53:20)
at NodePath.call (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:40:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:88:12)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitMultiple (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:85:17)
at TraversalContext.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:144:19)
at Function.traverse.node (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:94:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:95:18)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitMultiple (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:85:17)
at TraversalContext.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:144:19)
at Function.traverse.node (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:94:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:95:18)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitSingle (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:90:19)
at TraversalContext.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:146:19)
at Function.traverse.node (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:94:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:95:18)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitMultiple (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:85:17)
at TraversalContext.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:144:19)
at Function.traverse.node (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:94:17)
at NodePath.visit (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:95:18)
at TraversalContext.visitQueue (/app/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
@ ./src/app.js 5:0-40
@ multi ./src/app.js
Bazı eklentiler kurmam gerektiğini okudum, ama sanırım bu eski nodejs sürümleri için, nodejs'e gömülü bir özellik için neden bir eklentiye ihtiyacım olduğunu anlamıyorum.
Bunu nasıl yapabilirim?
Güncelleme:
Orada bir konu oluşturdum: https://github.com/babel/babel-loader/issues/798
Cevap #1
Babel sorumlusuyum.
v7.5.0 sürümünde bir hatamız var (yakında v7.5.1 sürümünde düzeltilecek). İki olası geçici çözümünüz var:
- Şunu çalıştırın
npm install @babel/helpers(ya da yarn ile): bu, npm'in eksik yardımcıyı içeren@babel/helpersv7.5.0 sürümünü indirmesini zorlayacaktır. Eğer ayrıca@babel/transform-runtimekullanıyorsanız,@babel/runtimesürümünün v7.5.0 olduğundan emin olun. Eğer yarn kullanıyorsanız,
@babel/plugin-proposal-object-rest-spreadpaketini sorundan etkilenmeyen eski bir sürüme kilitleyebilirsiniz. Bu kodu package.json dosyanıza ekleyin:"resolutions": { "**/@babel/plugin-proposal-object-rest-spread": "7.4.4" }
DÜZENLE Bu, v7.5.1'de düzeltilmiş olmalı, lütfen güncelleyin
