Skip to content

Commit

Permalink
fix: use ES6 module syntax for the output modules
Browse files Browse the repository at this point in the history
  • Loading branch information
skipjack committed Jan 24, 2018
1 parent 4e1e718 commit d550fa4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = function(resolved) {
jsx = jsx.replace(/(<(?:img|hr)[^>]*)>/g, '$1 />') // Please react
jsx = jsx.replace(/&#x3C;/g, '<') // Fix escaped react elements
jsx = jsx.replace(/<p>(<[A-Z][\s\S]*?)<\/p>/g, '$1') // Remove surrounding p tags from components
jsx = jsx.replace('module.exports = ', '') // Remove lead-in from html-loader
jsx = jsx.replace('export default ', '') // Remove lead-in from html-loader
jsx = jsx.slice(1, jsx.length - 2) // Remove quotes from around JSX
jsx = jsx.replace(/\\"" \+ (require\(".+?"\)) \+ "\\"/g, '{ $1 }') // Wrap html-loader `require`s
jsx = jsx.replace(/\\"/g, '"') // Unescape quotes
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function(content) {
Parse(content, options)
// TODO: Refactor this hack -- we should probably just intercept images in the tree
.then(processed => Object.assign({}, processed, {
content: HTMLLoader(processed.content)
content: HTMLLoader(processed.content).replace('module.exports = ', 'export default ')
}))
// TODO: Ideally this should be enabled via remark-react or another plugin (discuss with the author)
.then(resolved => options.react ? Build(resolved) : resolved)
Expand Down

0 comments on commit d550fa4

Please sign in to comment.