Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

babel-loader transform-runtime causes TypeError: __webpack_require__(...) is not a function #637

Closed
mo22 opened this issue Apr 6, 2017 · 12 comments

Comments

@mo22
Copy link

mo22 commented Apr 6, 2017

Hi,

not really sure yet how to reproduce this, but as soon as I add transform-runtime to my webpack config in babel-loader plugins, I get the following error, both in hot and production mode:

ERROR in TypeError: webpack_require(...) is not a function

  • default_index.ejs:120 Object.
    [form-react]/[html-webpack-plugin]/default_index.ejs:120:105

  • default_index.ejs:21 webpack_require
    [form-react]/[html-webpack-plugin]/default_index.ejs:21:30

  • default_index.ejs:11781 Object.
    [form-react]/[html-webpack-plugin]/default_index.ejs:11781:56

  • default_index.ejs:21 webpack_require
    [form-react]/[html-webpack-plugin]/default_index.ejs:21:30

  • default_index.ejs:10915 Object.
    [form-react]/[html-webpack-plugin]/default_index.ejs:10915:56

  • default_index.ejs:21 webpack_require
    [form-react]/[html-webpack-plugin]/default_index.ejs:21:30

  • default_index.ejs:11792 Object.
    [form-react]/[html-webpack-plugin]/default_index.ejs:11792:9

  • default_index.ejs:21 webpack_require
    [form-react]/[html-webpack-plugin]/default_index.ejs:21:30

  • default_index.ejs:67 module.exports.version
    [form-react]/[html-webpack-plugin]/default_index.ejs:67:18

  • default_index.ejs:70
    [form-react]/[html-webpack-plugin]/default_index.ejs:70:10

@heptahedron
Copy link

Getting the same error on [email protected] but not 2.3.1.

@mastilver
Copy link
Collaborator

Are you still getting that error?

Can any of you provide us with a webpack.config.js and your index file

@sdesmond
Copy link

sdesmond commented May 4, 2017

I'm seeing this too. Here are my details. I have a tiny "getting started" app that I can throw on GitHub if needed.

for my index file, if I do this, everything works fine:

module.exports = function(ngModule) {
    require('./sd-hello')(ngModule);
};

When I change it to this, I get the error __webpack_require__(...) is not a function:

export default function(ngModule) {
    require('./sd-hello')(ngModule);
};

webpack.config.js

module.exports = {
    context: __dirname + '/app',
    entry: './index.js',
    output: {
        path: __dirname + '/app',
        filename: 'bundle.js'
    },
    module: {
        loaders: [
            {test: /\.js$/, loader: 'babel-loader'}
        ]
    }
};

package.json

{
  "name": "webpack_starter",
  "version": "0.0.0",
  "license": "MIT",
  "dependencies": {
    "lodash": "4.17.4"
  },
  "devDependencies": {
    "@types/node": "7.0.16",
    "angular": "1.6.4",
    "babel-cli": "6.24.1",
    "babel-loader": "7.0.0",
    "css-loader": "0.28.1",
    "style-loader": "0.17.0",
    "ts-loader": "2.0.3",
    "typescript": "2.2.2",
    "webpack": "2.4.1",
    "webpack-dev-server": "2.4.5"
  },
  "scripts": {
    "build": "webpack",
    "start": "webpack-dev-server --content-base app"
  }
}

Thanks!

@mastilver
Copy link
Collaborator

mastilver commented May 4, 2017

@sdesmond Thank you, can you throw in your .babelrc at the same time please

@mastilver
Copy link
Collaborator

@sdesmond If you can create that repository, that would make debugging far more easier :)

@sdesmond
Copy link

sdesmond commented May 4, 2017

@mastilver
Copy link
Collaborator

mastilver commented May 4, 2017

@sdesmond Your issue doesn't have to do anything with html-webpack-plugin

Please read: https://medium.com/@kentcdodds/misunderstanding-es6-modules-upgrading-babel-tears-and-a-solution-ad2d5ab93ce0

@mo22 @heptahedron Closing this issue for now as I didn't hear from you

Feel free to reach out here again if you are still experiencing an issue

@sdesmond
Copy link

sdesmond commented May 4, 2017

Ha, ha. Guess who wrote the tutorial I'm going through? That's right, Mr. Dodds :-). Thanks!

@wlxscn
Copy link

wlxscn commented May 9, 2017

@sdesmond I have the same question.How do you resolve it?Can you share your webpack config? thanks

@sdesmond
Copy link

sdesmond commented May 9, 2017

The article @mastilver posted answered the issue for me. I was trying to cross CommonJS modules and ES6 modules. You have to stick to one or the other.

@wlxscn
Copy link

wlxscn commented May 10, 2017

thanks,I have resolved the question

@lock
Copy link

lock bot commented May 31, 2018

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants