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

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

lazy-load does not play well with nexe #66

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

Comments

@jd-carroll
Copy link

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
Copy link

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
Copy link

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
Copy link
Contributor

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
Copy link
Contributor

DABH commented May 23, 2019

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

@JakeDluhy
Copy link

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.

@55Cancri
Copy link

55Cancri commented Apr 4, 2020

Any update to this using parcel? I am using aws-cdk with parcel-bundler@^1 and failing for all format functions including combine.

@jd-carroll jd-carroll closed this as not planned Won't fix, can't repro, duplicate, stale Oct 7, 2022
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

No branches or pull requests

6 participants