babel: Object is not a function error using v7.13.x
Bug Report


Current behavior
my package.json using babel v6,while some package like react-redux using babel ^7.1.1. babel v6 comile v7.13.x to image above,i think thatis the question
- Babel version(s): [package.json v6 ,error package v7.13.x]
- Node/npm version: [v12]
- OS: [macos]
- How you are using Babel: [`webpack`]
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 20 (9 by maintainers)
@LeventLei This is a bug in
af-webpack(a dependency ofroadhog): it tells webpack “If an extension is not one ofhtml|ejs|json|js|jsx|ts|tsx|css|less|scss|sass, load it as a string URL instead of executing it”. Webpack’s default behavior would be to load.mjsfiles as JavaScript, butaf-webpackprevents it from doing so.As a workaround, you can add
urlLoaderExcludes: [/\.mjs$/, /\.cjs$/],to your.webpackrc.jsconfig (I also added.cjsbecause it’s another JS extension thataf-webpackdoesn’t handle correctly, even if it’s not related to the current error), but I strongly suggest reporting this bug toaf-webpackso that they can fix it.I found it directly in the
af-webpacksource code 😄thanks ,i solved this problem by adding mjs in webpack confg. { exclude: [ /.(js|jsx|mjs|html|json)$/], loader: ‘file-loader’, options: { name: config.mediaChunkFileName, }, }
why not use .js
@nicolo-ribaudo It really works for me , much appreciated
object-not-defined.zip this is my project simple,thanks @nicolo-ribaudo
I still can’t solve my problem, what else can I apply for your help @nicolo-ribaudo
Because:
The only problem is when you configure webpack to handle mjs files with a different loader (
file-loaderin your case).