ncc icon indicating copy to clipboard operation
ncc copied to clipboard

Asset relocation does not work for files that were processed with Babel

Open nwalters512 opened this issue 2 years ago • 0 comments

I've set up a reproduction here: https://github.com/nwalters512/ncc-babel-bug-repro. It includes instructions for reproducing.

AFAICT, the usage of _interopRequireDefault and the .default property access on the imported modules means that the usages of path and child_process aren't correctly identified. Specifically, this file (processed with Babel) does not result in worker.js being relocated:

"use strict";

function _interopRequireDefault(obj) {
  return obj && obj.__esModule ? obj : {
    "default": obj
  };
}

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _child_process = _interopRequireDefault(require("child_process"));

var _path = _interopRequireDefault(require("path"));

var load = function load() {
  return _child_process.default.spawnSync(process.execPath, [_path.default.join(__dirname, './worker.js')]);
};

var _default = load();

exports.default = _default;

Whereas this file (identical, expect manually edited to remove usages of _interopRequireDefault and .default) works as expected:

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _child_process = require("child_process");

var _path = require("path");

var load = function load() {
  return _child_process.spawnSync(process.execPath, [_path.join(__dirname, './worker.js')]);
};

var _default = load();

exports.default = _default;

nwalters512 avatar Aug 29 '22 20:08 nwalters512