Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Curtis Maloney
    @funkybob
    so, in fact, react-redux is attempting it
    Patricio Palladino
    @alcuadrado
    Curtis Maloney
    @funkybob
    yes, I went down that path
    wound up with about 50 entries across half a dozen packages
    what bothers me is ... NOBODY else seems to have this issue
    Patricio Palladino
    @alcuadrado
    I found multiple people with that issue on github
    Curtis Maloney
    @funkybob
    any solutions?
    the resolutions I find for similar problems is : "use commonjs plugin"
    Patricio Palladino
    @alcuadrado
    Because of how rollup works, and how react exports some things
    Curtis Maloney
    @funkybob
    so... the solution is (a) litter my config with dozens of special cases, so I can't easily spot a false import path, and (b) find a way to add pressure to react to, after over 2 years, resolve the ticket about releasing ESM packages
    disappointing, but I know it's not rollup's fault, per se
    ironically, the CJS modules react publish are produced by rollup...
    ah well, thanks for your input, @alcuadrado ...
    for now, I guess I'll just have to keep dreaming of moving this project off webpack and onto rollup :(
    Patricio Palladino
    @alcuadrado
    Yeah, I know, having multiple module formats is frustrating
    There may be a better solution though, I've only been using rollup for a week 😅
    Curtis Maloney
    @funkybob
    though that's for creating libs... should address the same issues
    Sam Selikoff
    @samselikoff
    hi folks! is it possible to "replace" a module for a particular build? I swear I saw it somewhere but I can't put my finger on it
    resolveId maybe?
    Curtis Maloney
    @funkybob
    you want to catch it during bundling and substitute your own?
    Jacob Bogers
    @Jacob_Bogers_twitter
    hey
    i am having a problem using 2 plugins
    Jacob Bogers
    @Jacob_Bogers_twitter
    it seems rollup-babel is not working well with rollup-typescript
    Curtis Maloney
    @funkybob
    is there perhaps a typescript plugin for babel?
    @Jacob_Bogers_twitter in what way is it "not working well"?
    Curtis Maloney
    @funkybob

    Interesting.. this is in the react bundle:

    // TODO: decide on the top-level export form.
    // This is hacky but makes it work with both Rollup and Jest.
    var react = React$3.default || React$3;
    
    module.exports = react;
      })();
    }

    AIUI this means doing "import { useMemo } from 'react'; " is, in fact, invalid...

    or does it mean {} can only reference what's in the react object?
    Patricio Palladino
    @alcuadrado

    This is my understanding from what I read when trying to help you:

    React is publishing CJS module and import {} from "" is an ESM feature. The combination of both only work because the tool you are using. Each tool does different things.

    Rollup converts CJS modules into ESM, and that turns react's module into something like export default react. If react were using module.exports.useMemo = ... rollup would detect that and create the appropriate ESM export.

    Webpack keeps everything in CJS so it works, because that import {} ... gets translated into an object destructuring, not an ESM named export and import.

    Curtis Maloney
    @funkybob
    webpack does fuck all, it seems... just concatenates files... so if you forget an import, but another module includes it... you get it! free! ...
    @alcuadrado right now I'm trying to find docs on commonjs, and if/how "exports" and "module.exports" differ...
    Patricio Palladino
    @alcuadrado

    AFAIK you can think of it as having this at the beginning of each file:

    const exports = module.exports

    They are the same as long as you don't reassign module.exports

    Curtis Maloney
    @funkybob
    so it's only module.exports that is meaningful to commonjs ?
    Patricio Palladino
    @alcuadrado
    you can use exports if you want, as long as you don't change module.exports
    by changing it I mean replacing the object, not just adding properties to it
    Curtis Maloney
    @funkybob
    I don't care what can be done... I care about what something that is CommonJS compliant cares about
    I know I can do all manner of things in code... I'm not interested in what my code is doing
    Patricio Palladino
    @alcuadrado
    this only mentions the variable exports http://www.commonjs.org/specs/modules/1.0/
    module may be a node-specific thing
    Curtis Maloney
    @funkybob
    right, but nobody else seems to do that
    they all refer to modules.exports
    https://www.sitepoint.com/understanding-module-exports-exports-node-js/
    The keyword require returns an object, which references the value of module.exports for a given file.
    Curtis Maloney
    @funkybob
    so it seems (a) the commonjs.org docs don't seem to match "reality", (b) react is doing the right thing, (c) the commonjs.org web site and IRC channel are quite atrophied
    if only @Rich-Harris or @sakulstra were here to answer :( They've both clearly been working on this problem at other times.
    Curtis Maloney
    @funkybob
    const exportsPattern = /^(?:module\.)?exports(?:\.([a-zA-Z_$][a-zA-Z_$0-9]*))?$/;
    looks like rollup-plugin-commonjs will accept either
    Curtis Maloney
    @funkybob
    so from what I'm seeing, for anything pulled through the commonjs plugin I should not be able to import { foo } from 'thepackage';
    fchpr
    @fchpr
    Hello everybody! Does anyone know if there's an equivalent (or sort of) Rollup plugin to:
    https://www.npmjs.com/package/mini-css-extract-plugin
    Thanks for your time.