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

lazy-load does not play well with nexe #66

Open
jd-carroll opened this issue Dec 3, 2018 · 5 comments
Open

lazy-load does not play well with nexe #66

jd-carroll opened this issue Dec 3, 2018 · 5 comments

Comments

@jd-carroll
Copy link

@jd-carroll jd-carroll commented Dec 3, 2018

We are facing an issue using this module with a nexe bundled project. Essentially nexe does not support any type of dynamic module imports.

Is there any specific reason why the transports are setup lazily?

@marcelfalliere

This comment has been minimized.

Copy link

@marcelfalliere marcelfalliere commented Jan 31, 2019

Same here. Our project bundle with parcel has problem starting because it cannot find colorize because it is imported dynamicly by logform. Culprit piece of code :

/*
 * @api private
 * method {function} exposeFormat
 * Exposes a sub-format on the main format object
 * as a lazy-loaded getter.
 */
function exposeFormat(name, path) {
  path = path || name;
  Object.defineProperty(format, name, {
    get() {
      return require(`./${path}.js`);
    },
    configurable: true
  });
}

Parcel does not support dynamic loading. Anyway, just pilling up on @jd-carroll issue.

@iameli

This comment has been minimized.

Copy link

@iameli iameli commented May 1, 2019

Hm yeah. Winston is quite useful for running in a variety of environments, it's a shame that it can't be built with Parcel and such.

@DABH

This comment has been minimized.

Copy link
Contributor

@DABH DABH commented May 1, 2019

logform / winston specify browser fields in package.json which is what bundlers like webpack use instead of the main fields. The versions of the files in browser do not use dynamic imports and so should be fine for your use cases
https://github.com/winstonjs/logform/blob/master/package.json
However, it seems parcel, nexe, etc. (I am not hip with all the bundlers unfortunately) are preferring the main field instead of the browser field, which feels like a bug with them since this is exactly what that field was intended for. Do you know if those bundlers have a similar/analogous field we should be setting in our package.json's? Or is there a way to make them not ignore browser?

@DABH

This comment has been minimized.

Copy link
Contributor

@DABH DABH commented May 23, 2019

Potentially fixed in winstonjs/winston#1640 but need to test...

@JakeDluhy

This comment has been minimized.

Copy link

@JakeDluhy JakeDluhy commented Aug 22, 2019

Not sure if this helps anyone, but I was having this problem using winston with electron (specifically from the main process, not the renderer). I was able to fix it by adding

resolve: {
  alias: {
    logform$: path.resolve(__dirname, 'node_modules', 'logform', 'dist', 'browser'),
  },
},

to my main process webpack config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.