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

Missing exports in project dependencies #77

Hopobcn opened this Issue Dec 16, 2017 · 4 comments


None yet
3 participants

Hopobcn commented Dec 16, 2017

I've found an issue (and a possible solution) when loading screps-profiler to a project. I add this issue in case it's useful for others.

Use case:

function ploop() {
  if (Config.USE_PROFILER) {
  } else {
export const loop = ErrorMapper.wrapLoop(ploop);

Expected behaviour:

  • Uploaded dist/main.js contains a bundled screeps-profiler

Actual behaviour:

$ yarn push-develop
yarn run v1.3.2
$ rollup -c --dest develop

src/main.ts → dist/main.js...
(!) Missing exports
enable is not exported by node_modules/screeps-profiler/screeps-profiler.js
5: // Screeps system reloads your script.
6: if (Config.USE_PROFILER) {
7:     Profiler.enable();
8: }
9: /*
wrap is not exported by node_modules/screeps-profiler/screeps-profiler.js
29: function ploop() {
30:     if (Config.USE_PROFILER) {
31:         Profiler.wrap(mloop);
32:     }
33:     else {

And dist/main.js has some undefined calls:

function ploop() {
    if (USE_PROFILER) {
    else {

In game console:

[10:07:40]TypeError: undefined is not a function
    at main:2356:5
    at eval:2398:4
    at Object.<anonymous>:2:143116
    at Object.r.runCode:2:143673

Possible Solution:

In rollup.config.js, add a namedExprots section to commonjs plugin to manually export enable and wrap functions.

      namedExports: {
        'node_modules/screeps-profiler/screeps-profiler.js': ['enable', 'wrap']

Maybe screeps-typescript-starter/docs/in-depth/ could be modified to specify the rollup.config.js modifications required.

Does anyone have a better solution than this?


This comment has been minimized.


resir014 commented Dec 17, 2017

Good catch! I'll go ahead and update those docs now.


This comment has been minimized.


resir014 commented Dec 17, 2017

@Hopobcn and to answer your question, unfortunately no. Rollup has first-class support for bundling ES6 modules, but screeps-profiler is a CommonJS module, which means the module along with its named exports need to be resolved using rollup-plugin-commonjs.

Webpack gets around this by making everything a CommonJS module and then reimplementing the CommonJS require() system client-side, which gets around the namedExports issue at the expense of larger bundle size (which explains the seemingly boilerplate code it generates).

I could be wrong though, @apemanzilla can probably correct me.


This comment has been minimized.


dmarcuse commented Dec 17, 2017

Yeah, this is an issue with the way screeps-profiler is written and a limitation of rollup unfortunately.


This comment has been minimized.


resir014 commented Dec 21, 2017

Anyways, the docs have been updated. This can be closed now.

@resir014 resir014 closed this Dec 21, 2017

@resir014 resir014 added the docs label Dec 21, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment