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
15 changes: 7 additions & 8 deletions gatsby-config.js → gatsby-config.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
const { generatePathPrefix } = require('./src/utils/generate-path-prefix');
const { siteMetadata } = require('./src/utils/site-metadata');
const { isGatsbyPreview } = require('./src/utils/is-gatsby-preview');
import { createRequire } from 'module';
import { generatePathPrefix } from './src/utils/generate-path-prefix.mjs';
import { siteMetadata } from './src/utils/site-metadata.mjs';
import { isGatsbyPreview } from './src/utils/is-gatsby-preview.mjs';

const isPreview = isGatsbyPreview();
const pathPrefix = !isPreview ? generatePathPrefix(siteMetadata) : undefined;

const require = createRequire(import.meta.url);

console.log('PATH PREFIX', pathPrefix);

// Specifies which plugins to use depending on build environment
Expand Down Expand Up @@ -32,8 +35,4 @@ if (!isPreview) {
});
}

module.exports = {
plugins,
pathPrefix,
siteMetadata,
};
export { plugins, pathPrefix, siteMetadata };
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@ module.exports = {
'^.+\\.jsx?$': `<rootDir>/jest-preprocess.js`,
},
},
{
displayName: 'tests-esm',
testMatch: ['<rootDir>/tests/tests-esm/**/*.test.js'],
},
],
};
Loading