From 2a00aa698c13abdfae04d39ff33ff2652d907786 Mon Sep 17 00:00:00 2001 From: Ismail Syed Date: Mon, 8 Mar 2021 20:09:48 -0500 Subject: [PATCH] Add ESM support for .mjs files --- next.config.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/next.config.js b/next.config.js index 7d5cf62a..a5d56171 100644 --- a/next.config.js +++ b/next.config.js @@ -5,9 +5,17 @@ const webpack = require("webpack"); const apiKey = JSON.stringify(process.env.SHOPIFY_API_KEY); module.exports = withCSS({ - webpack: config => { + webpack: (config) => { const env = { API_KEY: apiKey }; config.plugins.push(new webpack.DefinePlugin(env)); + + // Add ESM support for .mjs files in webpack 4 + config.module.rules.push({ + test: /\.mjs$/, + include: /node_modules/, + type: "javascript/auto", + }); + return config; - } + }, });