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

Improve webpack custom build support for external node packages #120

Merged
merged 1 commit into from
Oct 17, 2015

Conversation

haydnhkim
Copy link
Contributor

Use core-js custom build with webpack but, it doesn't work by path error.
I can show you a simple example.

step 1.

$ mkdir core-js-test && cd core-js-test

step 2.

$ npm install --save-dev webpack core-js

step 3. make test.js file

require('core-js/build')({
    modules: ['es5'],
    blacklist: ['es6.number.constructor'],
}, function(error, code) {
    if (error) {
      console.log('core-js build error');
      return;
    }
    console.log(code);
});

step 4. run test file

$ node test.js

you can see the console.log(code) in terminal.

/**
 * core-js 1.2.1
 * https://github.com/zloirock/core-js
 * License: http://rock.mit-license.org
 * © 2015 Denis Pushkarev
 */
!function(__e, __g, undefined){
'use strict';
/******/ (function(modules) { // webpackBootstrap
/******/    // The module cache
/******/    var installedModules = {};

/******/    // The require function
/******/    function __webpack_require__(moduleId) {

/******/        // Check if module is in cache
/******/        if(installedModules[moduleId])
/******/            return installedModules[moduleId].exports;

/******/        // Create a new module (and put it into the cache)
/******/        var module = installedModules[moduleId] = {
/******/            exports: {},
/******/            id: moduleId,
/******/            loaded: false
/******/        };

/******/        // Execute the module function
/******/        modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/        // Flag the module as loaded
/******/        module.loaded = true;

/******/        // Return the exports of the module
/******/        return module.exports;
/******/    }


/******/    // expose the modules object (__webpack_modules__)
/******/    __webpack_require__.m = modules;

/******/    // expose the module cache
/******/    __webpack_require__.c = installedModules;

/******/    // __webpack_public_path__
/******/    __webpack_require__.p = "";

/******/    // Load entry module and return exports
/******/    return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {

    (function webpackMissingModule() { throw new Error("Cannot find module \"./modules/es5\""); }());
    (function webpackMissingModule() { throw new Error("Cannot find module \"./modules/es6.object.freeze\""); }());
    (function webpackMissingModule() { throw new Error("Cannot find module \"./modules/es6.object.seal\""); }());
    (function webpackMissingModule() { throw new Error("Cannot find module \"./modules/es6.object.prevent-extensions\""); }());
    (function webpackMissingModule() { throw new Error("Cannot find module \"./modules/es6.object.is-frozen\""); }());
    (function webpackMissingModule() { throw new Error("Cannot find module \"./modules/es6.object.is-sealed\""); }());
    (function webpackMissingModule() { throw new Error("Cannot find module \"./modules/es6.object.is-extensible\""); }());
    (function webpackMissingModule() { throw new Error("Cannot find module \"./modules/es6.string.trim\""); }());


/***/ }
/******/ ]);
// CommonJS export
if(typeof module != 'undefined' && module.exports)module.exports = __e;
// RequireJS export
else if(typeof define == 'function' && define.amd)define(function(){return __e});
// Export to global object
else __g.core = __e;
}(1, 1);

I fixed it just replace absolute path instead of relative path of core-js modules.
and it works fine both npm run grunt build and external node package build.

@zloirock
Copy link
Owner

Ok, thanks.

zloirock added a commit that referenced this pull request Oct 17, 2015
Improve webpack custom build support for external node packages
@zloirock zloirock merged commit a249ff7 into zloirock:master Oct 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants