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.

Transpiled webpack bundle does not export hyphenated package name via require

See original GitHub issue

StackOverflow question Example Repo Breaking commit

The Main.js file within the app’s contents, after running npm run package, includes a line function(e,t){e.exports=fluent-ffmpeg}. When I try to open the app, I receive this error: Uncaught Exception: ReferenceError: fluent is not defined

I can fix this by manually editing the aforementioned line to read: function(e,t){e.exports=require("fluent-ffmpeg")}

Steps to reproduce

  • I cloned this repo
  • added the fluent-ffmpeg package
  • add import ffmpeg from 'fluent-ffmpeg' into main.development.js
  • npm run package
  • open app

My Example Repo shows this same error.

Any help with making fluent-ffmpeg work with this repo would be appreciated.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
the4dpatrickcommented, May 30, 2016

I was able to solve the issue by simply setting the output.libraryTarget within webpack.config.electron.js file.

output: {
    path: path.join(__dirname, 'dist'),
    filename: 'bundle.js',
    libraryTarget: 'commonjs2'
  },

@eugenehp with this boilerplate we could run npm run package to deliver the production app. @FraGoTe I was able to maintain externals being an array. The only possible change to this boilerplate that is related to this issue might be the setting output.libraryTarget

1reaction
the4dpatrickcommented, May 30, 2016

@eugenehp I can see where this can work after running the npm run dev command where the server is spun up for development, but after I want to package the application, I would need a separate API running to access ffmpeg. I want to be able to run fluent-ffmpeg apart of an offline application without spinning up a server.

I might have found a fix by changing externals inside the webpack.config.base.js to read:

externals: {
    'fluent-ffmpeg': 'fluent-ffmpeg'
  }

I have yet to confirm this actually works

Read more comments on GitHub >

github_iconTop Results From Across the Web

Transpiled webpack bundle does not export hyphenated ...
I was able to solve the issue by simply setting the output.libraryTarget setting within webpack.config.electron.js file to commonjs2 .
Read more >
Transpiled webpack bundle does not export hyphenated ...
I was able to solve the issue by simply setting the output.libraryTarget within webpack.config.electron.js file. output: { path: path.join(__ ...
Read more >
How to transpile ES modules with webpack and Node.js
Learn how webpack interacts with and supports ES modules in this deep dive tutorial on transpilation in Node.js.
Read more >
[Solved]-Webpack bundle license compliance?-node.js
Note that licenses of dependencies listed in the devDependencies are not included ... Transpiled webpack bundle does not export hyphenated package name via...
Read more >
Package exports - webpack
Such a package would only work in Node.js >= 14 and only when using import . It won't work with require() . Providing...
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