Comments (11)
Could you provide an example snippet please? AFAIK the spec requires the source map comment to be on it's own line. It's all described in this proposal. Nothing that hints at supporting the Less case.
Also this post points at it needing to be on it's own line.
Are you sure you are dealing with source maps and not source urls? I remember less had those.
Again a snippet would be very helpful to clarify.
from convert-source-map.
I'm not entirely clear on the difference between Source Map and Source Urls, so no, I'm not sure what I'm dealing with :)
Here's a link to bootstrap compiled with the options I mentioned above: http://pastebin.com/6Rb5tb40
lessc --source-map-map-inline -x bootstrap.less test.css
That's not the exact code I was using when I ran into this, but it's close.
from convert-source-map.
The sourcemap is broken up in a weird manner:
[....] inline-block{display:inline-block !important}}@media print{.hidden-print{display:none !important}}/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJm [...] == */
I mean its all on one line! The source map needs to be on a separate line.
Looks like minification broke it. I don't think that abides by the spec and would expect lots of tools to fail in parsing this out correctly.
Please file a bug with the authors of the tools that generated this.
Closing this for now as this is not something that we can fix here.
from convert-source-map.
I'm not actually seeing anywhere in the Source Map 3 Proposal that specifies that a source map needs to be on its own line. Am I being thick?
The source map is read fine by chrome/firefox, so if it's not explicitly said to need to be on its own line in the spec, isn't it better to allow it?
from convert-source-map.
@thlorenz Can you point me to where it says source maps need to be on their own line? I don't see anything that conclusively states source maps are required to be on their own line in a file in the proposal but I fully acknowledge I could be missing something.
Seems to me that if source maps don't explicitly need to be on their own line, then the error is with the CommentRegex.
from convert-source-map.
You may be right, but we need to confirm that other tools even handle source maps like that.
Pulling out a source map with regex becomes near impossible to get right without false positives (i.e. inside a string) once you don't assume them to be on a separate line.
As a test you could generate a browserify bundle and put all code on one line (including source map).
Then see if chrome can even still parse it. If that's the case I'm willing to consider to introduce a flag that makes convert-source-map look for source maps on same line.
from convert-source-map.
I can confirm that Chrome and Firefox will correctly parse a source all on one line in that manner. It works for both Javsacript as well as CSS maps. (http://pastebin.com/6Rb5tb40 is successfully parsed back to it's less files.)
I'm happy to put together a PR for you to add a flag for this if you want. If you're set on keeping the original regex as an option you could just add an additional regex called CommentRegexGreedy
or something and export another getter for it?
from convert-source-map.
Actually if you remove ?:^[ \t]*
in the two places it occurs in this regex it should work for your case.
Since we still have the $
to ensure it has to be at the end of the line we'd rule out in-string occurrences.
Therefore we may not even have to use a flag, but change the default behavior instead.
It'd be awesome if you could PR with that change along with some tests for your particular case and some that ensure that it won't match false positives, i.e. try to pull a source map from within a string.
Thanks.
from convert-source-map.
Sure thing, I'll try to put some tests together this afternoon. Changing the default behavior definitely seems more friendly.
from convert-source-map.
Actually this regex doesn't have the $
so we should add that.
from convert-source-map.
I can confirm that this pull request works for the pastebin we've been using in this thread.
from convert-source-map.
Related Issues (20)
- SourceMappingURL causing failure on Safari HOT 10
- Fail toComment with included content. HOT 1
- Tests fail due to charset issue HOT 8
- Update inline-source-map to 0.6 HOT 1
- What is the correct way to remove a property? HOT 2
- VM6510:1 Uncaught SyntaxError: Unexpected token u HOT 1
- Error when running angular2-seed build process?? HOT 1
- Support non-base64 encoded json? HOT 4
- Unclosed block error in map-file-comment-double-slash.css HOT 1
- Rogue sourceMappingURL comment trips up devtools HOT 1
- source-map file name with query parameter, causes source-map not found HOT 6
- Reduce package size HOT 10
- sourceMappingURL with non-base64 data URI not supported. HOT 9
- Protect against template strings HOT 16
- sourceMappingURL inside string literal
- Module not found: Error: Can't resolve 'fs'
- Braking typescript/nyc coverage report HOT 1
- Extract string methods, browser support
- Safe to remove safe-buffer HOT 1
- memory consumption for 1.9.0 HOT 5
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 convert-source-map.