If you are using Create React App (CRA) and want to use Framer on the latest version (as I am writing version 7.2.0) you can use Craco to not eject.
- Install Craco
- In a new file called craco.config.jsadd this line that will call a plugin that we will create:
const { ProvidePlugin } = require("webpack");
const webpackFramerTyperScriptPlugin = require("./craco-plugin-framer-typescript");
module.exports = {
  webpack: {
    plugins: [
      new ProvidePlugin({
        React: "react",
      }),
    ],
  },
  plugins: [{ plugin: webpackFramerTyperScriptPlugin }],
};
- Create the plugin in a file named craco-plugin-framer-typescript.js
const { loaderByName, addBeforeLoader } = require("@craco/craco");
module.exports = {
  overrideWebpackConfig: ({ webpackConfig, cracoConfig, pluginOptions, context: { env, paths } }) => {
    const ruleToAdd = {
      test: /\.mjs$/,
      include: /node_modules/,
      type: "javascript/auto",
    };
    addBeforeLoader(webpackConfig, loaderByName("file-loader"), ruleToAdd);
    return webpackConfig;
  },
};
Hopefully it can help someone else that want to use CRA + TypeScript + Latest version of Framer.