Skip to content

Commit 7193303

Browse files
lourdwardpeet
andauthored
refactor(gatsby-transformer-remark): Refactors out Bluebird usage in transformer-remark (#29638)
Co-authored-by: Ward Peeters <ward@coding-tech.com>
1 parent c560eaa commit 7193303

3 files changed

Lines changed: 6 additions & 11 deletions

File tree

packages/gatsby-transformer-remark/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
},
99
"dependencies": {
1010
"@babel/runtime": "^7.12.5",
11-
"bluebird": "^3.7.2",
1211
"gatsby-core-utils": "^2.1.0-next.1",
1312
"gray-matter": "^4.0.2",
1413
"hast-util-raw": "^4.0.0",

packages/gatsby-transformer-remark/src/__tests__/on-node-create.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const Promise = require(`bluebird`)
21
const _ = require(`lodash`)
32
const { onCreateNode } = require(`../on-node-create`)
43
const { graphql } = require(`gatsby/graphql`)

packages/gatsby-transformer-remark/src/extend-node-type.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const toHAST = require(`mdast-util-to-hast`)
66
const hastToHTML = require(`hast-util-to-html`)
77
const mdastToToc = require(`mdast-util-toc`)
88
const mdastToString = require(`mdast-util-to-string`)
9-
const Promise = require(`bluebird`)
109
const unified = require(`unified`)
1110
const parse = require(`remark-parse`)
1211
const stringify = require(`remark-stringify`)
@@ -116,7 +115,7 @@ module.exports = function remarkExtendNodeType(
116115
}
117116
let remark = new Remark().data(`settings`, remarkOptions)
118117

119-
for (let plugin of pluginOptions.plugins) {
118+
for (const plugin of pluginOptions.plugins) {
120119
const requiredPlugin = require(plugin.resolve)
121120
if (_.isFunction(requiredPlugin.setParserPlugins)) {
122121
for (let parserPlugin of requiredPlugin.setParserPlugins(
@@ -193,8 +192,8 @@ module.exports = function remarkExtendNodeType(
193192
if (process.env.NODE_ENV !== `production` || !fileNodes) {
194193
fileNodes = getNodesByType(`File`)
195194
}
196-
// Use Bluebird's Promise function "each" to run remark plugins serially.
197-
await Promise.each(pluginOptions.plugins, plugin => {
195+
// Use a for loop to run remark plugins serially.
196+
for (const plugin of pluginOptions.plugins) {
198197
const requiredPlugin = require(plugin.resolve)
199198
// Allow both exports = function(), and exports.default = function()
200199
const defaultFunction = _.isFunction(requiredPlugin)
@@ -204,7 +203,7 @@ module.exports = function remarkExtendNodeType(
204203
: undefined
205204

206205
if (defaultFunction) {
207-
return defaultFunction(
206+
await defaultFunction(
208207
{
209208
markdownAST,
210209
markdownNode,
@@ -220,10 +219,8 @@ module.exports = function remarkExtendNodeType(
220219
},
221220
plugin.pluginOptions
222221
)
223-
} else {
224-
return Promise.resolve()
225222
}
226-
})
223+
}
227224

228225
return markdownAST
229226
}
@@ -236,7 +233,7 @@ module.exports = function remarkExtendNodeType(
236233
// Execute the remark plugins that can mutate the node
237234
// before parsing its content
238235
//
239-
// Use Bluebird's Promise function "each" to run remark plugins serially.
236+
// Use for loop to run remark plugins serially.
240237
for (const plugin of pluginOptions.plugins) {
241238
const requiredPlugin = require(plugin.resolve)
242239
if (typeof requiredPlugin.mutateSource === `function`) {

0 commit comments

Comments
 (0)