Giter Site home page Giter Site logo

Cannot use within webpack about datauri HOT 11 CLOSED

data-uri avatar data-uri commented on May 31, 2024 14
Cannot use within webpack

from datauri.

Comments (11)

ibc avatar ibc commented on May 31, 2024 4

I'm sorry guys, I was very busy with work this year. Gonna check webpack, rollup pretty sonner.

Not true.

from datauri.

heldr avatar heldr commented on May 31, 2024 4

Just a recall that PRs are always welcomed in open-source community and behind the scenes we have humans writing codes. Apparently, shamming contributors sounds an easier path though 😄

But yes! I should have prioritized it somehow, and sorry for those waiting for.

Being very transparent, I totally forget about this issue(can I?) and sometime I'll fix/review it.

Cheers! 🍵

from datauri.

mikelambert avatar mikelambert commented on May 31, 2024 2

FWIW, seems there is a shebang-loader that will solve this problem for me within webpack. So the fact that I don't need to write my own loader/code (and others have encountered it with a few different npm modules out there), makes this feel like less of a datauri issue.

But I know there are numerous webpack issues about this, where they keep claiming it's the problem of the module authors, who are making libraries-that-are-also-scripts. (Since technically, # is technically not a valid javascript comment, and these are malformed JS files to include/require in a build setting.)

from datauri.

john-osullivan avatar john-osullivan commented on May 31, 2024 1

@mikelambert I'm in the same position you are, trying to get mjml up and running. How did you bring shebang-loader into your webpack config? Based on the usage, it looks like the loader must be explicitly referenced in the require. Does that mean I need to fork mjml and fix any requires to datauri? Or were you able to simply preface the require to mjml?

Update for anyone else in my shoes: This shebang-loader gets the job done, there's a closed issue on its repo which shows how to properly set the webpack config: JavascriptIsMagic/shebang-loader#2 . Note to Windows users like myself, that issue recommends that we use path.resolve() to match on the offending npm package. That didn't work for me because you need to accurately specify the whole path. It was easier to use a RegEx that accounted for the different line break characters: /node_modules(\/|\\)datauri(\/|\\)index\.js$/

from datauri.

DeedleFake avatar DeedleFake commented on May 31, 2024 1

I just checked. I can confirm that it works. Thank you.

from datauri.

heldr avatar heldr commented on May 31, 2024 1

Thank you all for reporting this and sorry for my absence last year. 🍵

from datauri.

mikelambert avatar mikelambert commented on May 31, 2024

Ah sorry for the delay in responding, just came to respond and saw you figured it out.

Just a heads-up, I was unable to get <mjml-style inline="inline"> working. I forget exactly, but that seems to pull in additional modules (as part of a css selector package, I think?), some of which do not work in a webpack environment since they do require(env.NODENEV === 'production' ? 'prod.js' : 'dev.js'). And even with a webpack.DEFINE_PLUGIN, webpack was having trouble when attempting to statically analyze that dependency.

Finally just gave up and am currently inlining my CSS in the tags where it's necessary (mainly to override link colors, which didn't work with a <style> tag due to some sort of precedence issues.)

from datauri.

heldr avatar heldr commented on May 31, 2024

I'm sorry guys, I was very busy with work this year. Gonna check webpack, rollup pretty sonner.

from datauri.

WouterVanherck avatar WouterVanherck commented on May 31, 2024

@john-osullivan @mikelambert How exactly did you resolve it?
I tried to do it both ways but none ended up working:

module.exports = {
  module: {
    ...
    loaders: [
       ...
       {
         test: /node_modules(\/|\\)npm(\/|\\)bin(\/|\\)npm-cli\.js$/,
         loaders: ['shebang', 'babel']
       }
     ]
  }
  ...
};

and

module.exports = {
  module: {
    ...
    rules: [
        {
          test: path.resolve(String(path.appSrc), 'node_modules/npm/bin/npm-cli.js'),
          use: 'shebang-loader',
        }
      ]
  }
  ...
};

I've included these in my webpack.config.prod.js.
My #! was located in npm-cli.js.
O'm in "[email protected]"

from datauri.

mir3z avatar mir3z commented on May 31, 2024

What is the status of this issue? It's more that one year old!

from datauri.

heldr avatar heldr commented on May 31, 2024

v2.0 FINALLY released https://github.com/data-uri/datauri/releases/tag/v2.0.0

Could any of you please recheck if it fixes webpack compatibility?

from datauri.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.