R
R
retyui2016-12-02 23:49:37
webpack
retyui, 2016-12-02 23:49:37

How to get rid of duplicate _interopRequireDefault code generated by babel-loader?

A snippet of my webpack config :

{
            test: /\.js$/,
            exclude: /node_modules/,
            loader: `babel-loader`,
            query: {
                presets: [`es2015`],
                plugins: [
                    ['transform-runtime', {
                      helpers: true,
                      polyfill: false,
                      regenerator: false, }]
                    ]
            }
        }

I'm using transform-runtime 6.х.х version
But still it doesn't put everything into a separate module, the code duplicates and duplicates everything
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//...

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sly Fox, 2017-01-11
@unst0ppable

I'm not a js specialist, but if you go to the babel-runtime sources, then this function is duplicated inside the helpers themselves (although it exists as a helper, but is not connected in other helpers) + it is also duplicated in the project code by babel. As a result, there are a lot of these duplicates. I don't know why they did it. I think it might be better to use: Documentation External helpers , and disable runtime helpers

S
Sergey Goryachev, 2017-03-30
@a16a

Regular block with shadow.
The two back elements via pseudo elements, with a z-index lower than the main one.
https://jsfiddle.net/webirus/j85931f5/2/

A
Andrey Tokmakov, 2017-03-31
@NPC

Slightly modernized the answer Sergey Goryachev :
Looks like? :)
https://jsfiddle.net/j85931f5/5/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question