question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Bundling breaks in 6.2.9

See original GitHub issue

I just noticed the bundling breaks in the latest version (6.2.9). I’ll follow this up with more details shortly.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:4
  • Comments:6

github_iconTop GitHub Comments

6reactions
Poolsharkcommented, Apr 8, 2022

I guess I have a similar problem. I have updated to webpack 5.72.0 and now I get the error:

ERROR in ../../../.yarn/__virtual__/framer-motion-virtual-db281f3046/0/cache/framer-motion-npm-6.2.9-a9d36266d7-3ba830affd.zip/node_modules/framer-motion/dist/es/utils/process.mjs 9:25-32

BREAKING CHANGE: The request 'process/browser' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.

Framer motion version is v6.2.9

UPDATE

I have managed to get it working! 🙌 I’m not really sure what I’m doing anymore - literally randomly trying out things to get stuff working… What has happened to the JavaScript world? Almost every package I had was updated and resulted in breaking changes - I need a new job 🙈

Solution (at least for me): Use Webpack’s ProvidePlugin to resolve the missing variable process. I personally use Craco so I had to add to the craco.config.js:

const webpack = require("webpack");

module.exports = {
  ...
  webpack: {
    plugins: {
      add: [new webpack.ProvidePlugin({ process: "process/browser.js" })]
    }
  }  
}

Don’t forget to install via yarn add -D process

The key was to add the extension “.js” to process/browser - guess this is the same if you use webpack only.

1reaction
matt-allancommented, Sep 6, 2022

Here’s a more detailed error from Webpack:

ERROR in ../../node_modules/framer-motion/dist/es/utils/process.mjs 5:17-24
Module not found: Error: Can't resolve 'process/browser' in '/home/matt/code/my-project/node_modules/framer-motion/dist/es/utils'
Did you mean 'browser.js'?

BREAKING CHANGE: The request 'process/browser' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.

If you look at the file it’s complaining about you see:

/**
 * Browser-safe usage of process
 */
var defaultEnvironment = "production";
var env = typeof process === "undefined" || process.env === undefined
    ? defaultEnvironment
    : process.env.NODE_ENV || defaultEnvironment;

export { env };

My understanding of what’s happening is:

  1. Webpack reads the exports from package.json which point to the ESM build (not the CJS build)
  2. The ESM build of utils/process ends in .mjs so it’s treated as an ESM module by Node and Webpack
  3. The Webpack Provide plugin rewrites process to process/browser which is a module path
  4. Since it’s considered an ESM module but it now has a module path and that’s not allowed for ESM modules Webpack throws an error

The issue isn’t really in the Framer Motion package; it’s that the ProvidePlugin configuration is injecting a Node style module specifier into an ESM module.

If you don’t need process to work for other packages the simplest fix is to just remove that ProvidePlugin from you configuration. If that’s the only Framer Moton code using process it should work fine without the polyfill.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Known issues - Fortinet Documentation Library
The following issues have been identified in version 6.2.9. To inquire about a particular bug or report a bug, please contact Customer Service...
Read more >
FortiOS 6.2.5 Release Notes - Amazon AWS
Amazon AWS enhanced networking compatibility issue ... Prevent BGP daemon crashing when peer breaks TCP connection.
Read more >
Atlassian Plugin SDK - Windows - Version history
Version history · ATLASSDK-15: Plugin SDK installer overwrites users Path on Windows · ATLASSDK-78: Severe errors appearing in Confluence logs when using atlas- ......
Read more >
Cisco Firepower Release Notes, Version 6.2.3 Patches
Depending on how and when a bug was categorized or updated in our system, ... CSCvs84578: Upgrading FTD on 4100/9300 Platform to 6.2.3.15...
Read more >
Change Logs — PyArmor 7.6.0 documentation
The scripts are obfuscated by old version could not work with this version, they must be obfuscated again. 6.2.9¶. Fix cross platform bug:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found