Comments (8)
The warning doesn't come from this code...
The code fine... ok it has some issues:
- Don't require the
raw-loader
. Remove this linerequire("raw-loader");
- Double
!!
is ignored. The correct syntax isrequire("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.
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.
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.
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.
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.
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.
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.
from raw-loader.
Related Issues (20)
- [question] how to use the new asset modules with inline requires like you could with raw loader HOT 9
- raw-loader returns export string instead of file content HOT 1
- Export incompatibility with raw-loader and awesome-typescript-loader HOT 3
- The variable contains the path to the file instead of the text HOT 4
- Cannot import file using typescript HOT 6
- Imported string contains module.exports HOT 4
- Module parse failed: Unexpected token m in JSON at position 0 while parsing near 'module.exports = "{\...' HOT 5
- raw-loader 2.0 not working with pug-html-loader HOT 8
- Not working with require statements HOT 12
- Warning/Failure Using Raw Loader 2.0.0 in Angular CLI HOT 4
- error when using with SCSS and angular7 HOT 6
- Angular and Styles HOT 2
- The template specified for component AppComponent is not a string HOT 3
- version 2.0.0 breaks ng Angular 8 -> webpack in my project HOT 5
- You may need an appropriate loader to handle this file type. HOT 3
- [Bug Report] raw-loader failed to load *.json HOT 2
- Can raw-loader catch all HOT 3
- `Module not found` when using TypeScript project references HOT 2
- Module Not Found HOT 1
- Watch not working HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from raw-loader.