GithubHelp home page GithubHelp logo

Comments (8)

sokra avatar sokra commented on May 29, 2024

The warning doesn't come from this code...

The code fine... ok it has some issues:

  • Don't require the raw-loader. Remove this line require("raw-loader");
  • Double !! is ignored. The correct syntax is require("raw!excisor/templates/highlight.txt.mustache");

But this issues do not produce this warning.

The warning is emitted by including the file without the raw-loader. But not with a normal require, this would produce an error. I think it's included by a context. The warning should include the origin module. I'll find the origin of that module by compiling with --display-reasons. This will print the reasons why a module is included.


Example code that would produce this warning:

require("excisor/" + expression + "k.txt.mustache");
WARNING in ./book.txt.mustache
Module parse failed: .../book.txt.mustache Line 4: Unexpected token ILLEGAL

{{#highlights}}{{> highlight}}{{/highlights}}
{{^highlights}}You have no highlights for this book yet.{{/highlights}}
 @ ./node_modules/excisor ^\.\/.*k\.txt\.mustache$

The last line is the origin module, which can be traced back to the test.js file:

   [1] ./node_modules/excisor ^\.\/.*k\.txt\.mustache$ 184 [built] {0}
       cjs require context . [0] ./test.js 3:0-47

from raw-loader.

altano avatar altano commented on May 29, 2024

Ah, I thought double !! meant that it would ignore other loaders and just use "raw" which I was using to debug.

Anyway, you're absolutely right, webpack is trying to load those mustache templates without the raw loader. Unfortunately it isn't displaying a reason:

...
[18] ./src/excisor/templates/book.jade.js 886 [built] {0}
     context element ./templates/book.jade.js [11] ./src/excisor ^\.\/.*$
     context element ./book.jade.js [10] ./src/excisor/templates ^\.\/.*\.jade\.js$
[19] ./src/excisor/templates/book.txt.mustache -1 [built]
[20] ./src/excisor/templates/highlight.txt.mustache -1 [built]
[21] ./~/change-case/index.js 1733 [built] {0}
     cjs require change-case [8] ./src/excisor/templates.js 21:17-39
...

I'll try to track down the cause.

Thanks!

from raw-loader.

altano avatar altano commented on May 29, 2024

If I add an entry that matches these files to the "loaders" list in the Grunt config, these errors go away. That makes me think that webpack is not using raw as the default loader or something like that. I'll look through the source code tomorrow.

from raw-loader.

sokra avatar sokra commented on May 29, 2024

To ignore other loaders: require("!!raw!excisor/templates/highlight.txt.mustache");. see here

I've added reasons to failed modules. Now it may be easier to trace them back.

webpack do not use any loader by default. If you want them you have to configure them...


From you output I can see that module 11 is the origin of that: [11] ./src/excisor ^\.\/.*$ check the reasons of this module.

from raw-loader.

altano avatar altano commented on May 29, 2024

module 11 was added by webpack to support dynamic require. I noticed that an entry in the map was "templates" which should have referred to "templates.js" and not the "templates" directory which contained the .mustache file that is erroneously being required. I renamed templates.js to templateHelper.js to try and narrow it down. The code now looks like this:

    /***/ 9:
    /***/ function(module, exports, require) {

        var map = {
            "./Book": 6,
            "./Book.js": 6,
            "./Highlight": 7,
            "./Highlight.js": 7,
            "./amazonScraper": 5,
            "./amazonScraper.js": 5,
            "./stylesheets/book.less": 28,
            "./templateHelper": 8,
            "./templateHelper.js": 8,
            "./templates/book.jade": 31,
            "./templates/book.jade.js": 18,
            "./templates/highlight.jade": 32
        };
        function webpackContext(req) {
            return require(webpackContextResolve(req));
        };
        function webpackContextResolve(req) {
            return map[req] || (function() { throw new Error("Cannot find module '" + req + "'.") }());
        };
        webpackContext.keys = function webpackContextKeys() {
            return Object.keys(map);
        };
        webpackContext.resolve = webpackContextResolve;
        module.exports = webpackContext;
    /***/ },

(note that it is now 9: this is the same module, I just changed some other code that resulted in 11 becoming 9)

And I'm still getting the error, despite "templates" now not showing up in the map. Is this an issue with webpack requiring the file without using the raw loader to help support dynamic require in some way that isn't obvious?

I was planning on moving away from this dynamic require for an unrelated reason. I'm going to do that and see if it solves the issue. If you'd like to see my complete generated debug source code to see what is going on more clearly, let me know where I can email it. Otherwise I'll let you know if getting rid of the dynamic require fixes it.

from raw-loader.

altano avatar altano commented on May 29, 2024

Hmm, I got rid of these dynamic requires, module 9 is now gone, and the errors are gone. This was clearly the culprit. I will have time later today to take a look at the webpack source and try to determine exactly what was going on.

Btw, I updated webpack to beta15 but didn't get more output around the module require reasons.

from raw-loader.

altano avatar altano commented on May 29, 2024

By the way, I published the handlebars-loader. Please feel free to give me a code review and be very critical as I probably did many things wrong.

Thanks!

from raw-loader.

sokra avatar sokra commented on May 29, 2024

pcardune/handlebars-loader#1

from raw-loader.

Related Issues (20)

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.