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.

expose-loader works in Chrome but not FireFox?

See original GitHub issue

Hi there!

After some issues with upgrading from 0.7.5 to 2.0.0 everything where fine with expose-loader thanks to @alexander-akait (Issue#129), until we tested in Firefox and we got several errors.

First off these ones works in both FF(Version 88) and Chrome(Version 89.0.4389.128):

import "expose-loader?exposes=React!react";
import "expose-loader?exposes=ReactDOM!react-dom";
import "expose-loader?exposes=moment!moment";
import "expose-loader?exposes=Tours!./tours.js";

Then we have several entrys like this:

   entry: {
    bla: ["./bla"],
    bla_app: ["./bla_app"],
    bla2: ["@babel/polyfill", "./bla2"], 
    bla3: ["./bla3"],
    bla4: ["./bla4"],
    bla_5: ["@babel/polyfill", "./SinglePage/bla_5.js"], 
    bla_6: ["@babel/polyfill", "./SinglePage/bla_6.js"],
    },

each entry has its own set of react components that we need to expose to our Razors views to be rendered: import "expose-loader?exposes=Components!./bla_index.js";

This works without problem in chrome, but fails in FF: Uncaught Error: [exposes-loader] The "Components" value exists in the global scope, it may not be safe to overwrite it, use the "override" option and every component from bla_index.js that should be renderd gets undefined. React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

If I add this to webpack:

{
test: require.resolve("./App/bla_index.js"),
loader: "expose-loader",
options: {
	exposes: {
		    globalName: "Components",
		    override: true,
		},
	},
},

For every file that has its own set of components, this results in 5 of these. Then I can change the import to: import "./bla_index.js"; I can even leave it: import "expose-loader?exposes=Components!./bla_index.js";

Now both FF and Chrome works, if I take away the import completely both of them stop working.

What’s in play here? What is it I’m misunderstand?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
J4v4Scr1ptcommented, May 5, 2021

Well I’m not going to bother you more with this “issue”, thanks for the discussion. Awesome help like always 😀! Keep up your awesome work ppl! ✨

1reaction
alexander-akaitcommented, May 5, 2021

You can write console.log(code) https://github.com/webpack-contrib/expose-loader/blob/master/src/index.js#L100 and you will see it

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cant get new versions of expose-loader to work #129 - GitHub
Expose Loader has been initialized using an options object that does not match the API schema. - options misses the property 'exposes'.
Read more >
websites working on Chrome but not on Firefox - Mozilla Support
I make my accounting on a dedicated website and it's no longer possible to get an overview of the PDF I downloaded. It...
Read more >
Jquery Loader working on Chrome and not on FireFox?
I have this code for a loading spinner, it works on Chrome Android, but I can't figure out why it doesn't work on...
Read more >
expose-loader - webpack
Disclaimer: expose-loader is a third-party package maintained by community members, it potentially does not have the same support, security policy or ...
Read more >
Firefox/Tweaks - ArchWiki - Arch Linux
In about:config set network.protocol-handler.expose.magnet to false . In case it does not exist, it needs to be created, right click on a ...
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