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

Parse functions annotated #192

Closed
gregberge opened this issue Dec 27, 2018 · 1 comment
Closed

Parse functions annotated #192

gregberge opened this issue Dec 27, 2018 · 1 comment

Comments

@gregberge
Copy link
Owner

🚀 Feature Proposal

Actually Babel plugin relies on loadable, it would be great to rely on a comment too. See #188.

Motivation

See #188.

Example

/* #__LOADABLE__ */
const loader = () => import('./MyComponent');
var loader = function () {
  return {
      chunkName: function chunkName() {
        return "my-component";
      },
      isReady: function isReady(props) {
        if (typeof __webpack_modules__ !== 'undefined') {
          return !!__webpack_modules__[this.resolve(props)];
        }

        return false;
      },
      requireAsync: function requireAsync() {
        return import(
        /* webpackChunkName: "my-component" */
        './MyComponent');
      },
      requireSync: function requireSync(props) {
        var id = this.resolve(props);

        if (typeof __webpack_require__ !== 'undefined') {
          return __webpack_require__(id);
        }

        return eval('module.require')(id);
      },
      resolve: function resolve() {
        if (require.resolveWeak) {
          return require.resolveWeak("./MyComponent");
        }

        return require('path').resolve(__dirname, "./MyComponent");
      }
    }
@tagoro9
Copy link
Contributor

tagoro9 commented Feb 4, 2019

Hello. I would like to help with this.

I have a working POC that works for the above example an also for object properties that also have the comment like:

const data = {
  /* #__LOADABLE__ */
  loader: () => import('moment')
}

I am gonna try to create a PR soon with it.

tagoro9 added a commit to tagoro9/loadable-components that referenced this issue Feb 4, 2019
Transpile imports inside code annotated with `/* #__LOADABLE__ * /`.

Fixes gregberge#192
tagoro9 added a commit to tagoro9/loadable-components that referenced this issue Feb 4, 2019
Transpile imports inside code annotated with `/* #__LOADABLE__ * /`.

Fixes gregberge#192
tagoro9 added a commit to tagoro9/loadable-components that referenced this issue Feb 4, 2019
Transform imports inside code annotated with `/* #__LOADABLE__ * /`.

Fixes gregberge#192
tagoro9 added a commit to tagoro9/loadable-components that referenced this issue Feb 4, 2019
Transform imports inside code annotated with `/* #__LOADABLE__ * /`.

Fixes gregberge#192
gregberge pushed a commit that referenced this issue Feb 5, 2019
Transform imports inside code annotated with `/* #__LOADABLE__ * /`.

Fixes #192
gregberge pushed a commit that referenced this issue Feb 5, 2019
Transform imports inside code annotated with `/* #__LOADABLE__ * /`.

Fixes #192
gregberge pushed a commit that referenced this issue Feb 5, 2019
Transform imports inside code annotated with `/* #__LOADABLE__ * /`.

Fixes #192
gregberge pushed a commit that referenced this issue Feb 5, 2019
Transform imports inside code annotated with `/* #__LOADABLE__ * /`.

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

No branches or pull requests

2 participants