Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Add "inline" option for inline source maps. #1445

Merged
merged 3 commits into from
Jul 14, 2016

Conversation

jacksonrayhamilton
Copy link
Contributor

Fixes #1424.

@@ -188,6 +188,11 @@ const optimize = (data, map, path, optimizers, sourceFiles) => {
return promiseReduce(optimizers, runOptimizer, initial);
};

const getInlineSourceMapUrl = map => {
const base64String = new Buffer(JSON.stringify(map)).toString('base64');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new Buffer is deprecated in Node 6, use Buffer.from

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure Buffer.from is not available (yet) in Node 4

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brunch claims to support Node >= 4, and Buffer.from was only added in 5.10. So, for backwards compatibility, should I do this?

const base64String = (Buffer.from ? Buffer.from(JSON.stringify(map)) : new Buffer(JSON.stringify(map))).toString('base64');

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buffer.from for strings was added in 5.10: this code will cause TypeError in Node 4, because Buffer.from will expect TypedArray.

Lets leave new Buffer, I will containbase64 encoding complexity in helper later.

@jacksonrayhamilton
Copy link
Contributor Author

I removed the charset parameter, but afterwards I saw browserify/browserify#753 which seems to indicate we should keep it... is it OK if I revert #2b74535?

@shvaikalesh
Copy link
Contributor

OK, lets keep it.
PR LGTM.

@paulmillr paulmillr merged commit f7496f3 into brunch:master Jul 14, 2016
paulmillr pushed a commit to brunch/brunch.github.io that referenced this pull request Jul 14, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants