Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOP-3009: Convert snooty-frontend to use ESM style imports at build time #963

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"clipboard": "^2.0.8",
"dotenv": "^8.2.0",
"eventsource": "^2.0.2",
"gatsby": "^5.3.0",
"gatsby": "^5.8.0",
"gatsby-plugin-emotion": "^8.0.0",
"gatsby-plugin-google-tagmanager": "^5.0.0",
"gatsby-plugin-layout": "^4.7.0",
Expand Down
13 changes: 6 additions & 7 deletions plugins/gatsby-source-snooty-preview/gatsby-node.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { getDataStore } from 'gatsby/dist/datastore';
import path from 'path';
import { dirname } from 'path';
import { getDataStore } from 'gatsby/dist/datastore/index.js';
import path, { dirname } from 'path';
import { fileURLToPath } from 'url';
import stream from 'stream';
import { promisify } from 'util';
import got from 'got';
import { createRequire } from 'module';
import { parser } from 'stream-json/jsonl/Parser';
import { sourceNodes } from './other-things-to-source.mjs';
import parser from 'stream-json/jsonl/Parser.js';
import { sourceNodes as sourceNodesLocal } from './other-things-to-source.mjs';
import { fetchClientAccessToken } from './utils/kanopy-auth.mjs';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not sure what the best alias for this function would be, maybe sourceNodesOld? idk

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think sourceNodesLocal works. Or sourceMiscNodes? We can probably even change the exported function's name directly instead of using an alias, to make whichever name we go with clearer.

import { callPostBuildWebhook } from './utils/post-build.mjs';
import {
Expand Down Expand Up @@ -128,7 +127,7 @@ export const sourceNodes = async ({
// Since there's a lot of data incoming from the Snooty Data API, we stream
// the data in chunks and parse them as they come instead of fetching everything
// as a single JSON response
const decode = parser();
const decode = new parser();
decode.on('data', async (_entry) => {
// Un-nest data
const entry = _entry.value;
Expand Down Expand Up @@ -158,7 +157,7 @@ export const sourceNodes = async ({

// Source old nodes.
console.time(`old source nodes`);
await sourceNodes({
await sourceNodesLocal({
hasOpenAPIChangelog,
github_username: GATSBY_CLOUD_SITE_USER,
createNode,
Expand Down
3 changes: 1 addition & 2 deletions plugins/gatsby-source-snooty-prod/gatsby-node.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import path from 'path';
import { dirname } from 'path';
import path, { dirname } from 'path';
import { fileURLToPath } from 'url';
import { createRequire } from 'module';
import { transformBreadcrumbs } from '../../src/utils/setup/transform-breadcrumbs.mjs';
Expand Down
Loading