Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load module with default export #30

Open
hboylan opened this issue Nov 4, 2019 · 1 comment
Open

Load module with default export #30

hboylan opened this issue Nov 4, 2019 · 1 comment

Comments

@hboylan
Copy link

hboylan commented Nov 4, 2019

I'm currently unable to load a module that uses a default export. Specifically, styled-components uses default to conveniently wrap html elements which appears to break the loader.

To reproduce, try adding styled-components to your namespace. It should be added to the namespace, but webpack will be unable to load the default import at runtime.

use: {
  loader: 'share-loader',
  options: {
    modules: ['styled-components'],
    exclude: [],
    namespace: 'test',
  }
}
@hboylan
Copy link
Author

hboylan commented Nov 5, 2019

More clarity on this issue...

Import the default styled object.

import styled from 'styled-components'
console.log(styled)

const MyButton = styled.button`` # throws error

Notice how the default object is nested one level from the window namespace.

ServerStyleSheet: ƒ ServerStyleSheet()
StyleSheetConsumer: {$$typeof: Symbol(react.context), _context: {…}, _calculateChangedBits: null, …}
StyleSheetContext: {$$typeof: Symbol(react.context), _calculateChangedBits: null, _currentValue: undefined, _currentValue2: undefined, _threadCount: 0, …}
StyleSheetManager: ƒ StyleSheetManager(props)
ThemeConsumer: {$$typeof: Symbol(react.context), _context: {…}, _calculateChangedBits: null, …}
ThemeContext: {$$typeof: Symbol(react.context), _calculateChangedBits: null, _currentValue: undefined, _currentValue2: undefined, _threadCount: 0, …}
ThemeProvider: ƒ ThemeProvider(props)
createGlobalStyle: ƒ createGlobalStyle(strings)
css: ƒ css(styles)
default: ƒ styled(tag)
isStyledComponent: ƒ isStyledComponent(target)
keyframes: ƒ keyframes(strings)
withTheme: ƒ withTheme(Component$$1)
__DO_NOT_USE_OR_YOU_WILL_BE_HAUNTED_BY_SPOOKY_GHOSTS: {StyleSheet: ƒ}
__proto__: Object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant