faceyspacey / babel-plugin-universal-import

🍾 universal(props => import(`./${props.page}`)) + dual css/js imports
MIT License
114 stars 41 forks source link

Magic comments with importCss #73

Closed yoshi95 closed 5 years ago

yoshi95 commented 5 years ago

Hi,

with this source code

const MainComponent = universal(
  ({ pageType }) => import(
    /* webpackInclude: /\.\/(product|category|home|division)-page\/index\.js$/ */
    /* webpackExclude: /\/node_modules\// */
    `@my-ui/${pageType}-page`
  ),
  {
    loading: Loading,
    error: GeneralNoResult,
  }
);

i am seeing the output of the transpiled source for webpackInlcude, webpackExclude moved to the importCss promise instead of the the 1st promise.

shouldnt webpackInlcude/Exclude be part of the 1st promise (in the webpackChunkName import)? right now webpack doesnt see the options passed in when i debug

return (0, _universalImport3.default)({
    id: '@my-ui/${pageType}-page',
    load: function load() {
      return Promise.all([import( /* webpackChunkName: '@my-ui/[request]' */'@my-ui/' + pageType + '-page'), (0, _importCss3.default)(
      /* webpackExclude: /\/node_modules\// */
      '@my-ui/' + pageType + '-page', {})]).then(function (proms) {
        return proms[0];
      });
    },
    path: function path() {
      return _path3.default.join(__dirname, '@my-ui/' + pageType + '-page');
    },
    resolve: function resolve() {
      return require.resolveWeak('@my-ui/' + pageType + '-page');
    },
    chunkName: function chunkName() {
      return '@my-ui/' + pageType + '-page';
    }
  });

thanks in advance

yoshi95 commented 5 years ago

odd, i see this in the compiled source code, but looks like importCss is removed in 3.x.x, so maybe it s my local? wondering what does 3.x.x do with css import then...


var _importCss2 = require('babel-plugin-universal-import/importCss');

var _importCss3 = _interopRequireDefault(_importCss2);
yoshi95 commented 5 years ago

looks like this is related to my local having multiple .babelrc defined at diff folders.

closing, sorry for the spam