Skip to content

Export locals as ES2015 Modules #43

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

Closed
calebeby opened this issue Mar 18, 2018 · 3 comments
Closed

Export locals as ES2015 Modules #43

calebeby opened this issue Mar 18, 2018 · 3 comments

Comments

@calebeby
Copy link

Hi,

Right now when I use this plugin my bundle ends up having a bunch of these:

function(e, t, n) {
    e.exports = {
      home: "home_4zXj",
      headerContents: "headerContents_fgfT",
      info: "info_SpI-",
      dcmp: "dcmp_7LbX",
      cmp: "cmp_FYP2",
      pre: "pre_1JF_",
      off: "off_2kzf",
      adminPanel: "adminPanel_VjUM",
      navigationDrawerButtonContainer: "navigationDrawerButtonContainer_Gjyw",
      navigationDrawerButton: "navigationDrawerButton_11km"
    };
  }

Since this does not use es6 exports and instead uses module.exports, webpack is unable to inline these. If this plugin did use es6 exports, my bundle size would be much smaller because they could be inlined:

Code coming out of this plugin:

export const home = "home_4zXj";
export const headerContents = "headerContents_fgfT";
export const info = "info_SpI-";
// etc.

export default {
  home: "home_4zXj",
  headerContents: "headerContents_fgfT",
  info: "info_SpI-",
  dcmp: "dcmp_7LbX",
  cmp: "cmp_FYP2",
  pre: "pre_1JF_",
  off: "off_2kzf",
  adminPanel: "adminPanel_VjUM",
  navigationDrawerButtonContainer: "navigationDrawerButtonContainer_Gjyw",
  navigationDrawerButton: "navigationDrawerButton_11km"
};

Then, after Webpack processes it, the css module would be inlined, and unused properties would be removed.

I made a fork of extract-text-webpack-plugin that does this: webpack-contrib/extract-text-webpack-plugin@master...calebeby:master

Would you accept a similar PR to this repo?

Thanks!!!

@alexander-akait
Copy link
Member

@calebeby PR welcome

@Jessidhia
Copy link
Contributor

I believe @michael-ciniawsky was working on something like this for the new css-loader.

@michael-ciniawsky michael-ciniawsky changed the title Use ES6 Modules for locals Export locals as ES2015 Modules Aug 24, 2018
@michael-ciniawsky michael-ciniawsky added this to the 1.0.0 milestone Aug 24, 2018
@alexander-akait
Copy link
Member

close in favor #424

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

Successfully merging a pull request may close this issue.

4 participants