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

AMD define doesn't work for dynamic import? #1512

Open
1 of 5 tasks
jesse23 opened this issue Oct 25, 2019 · 0 comments
Open
1 of 5 tasks

AMD define doesn't work for dynamic import? #1512

jesse23 opened this issue Oct 25, 2019 · 0 comments

Comments

@jesse23
Copy link

jesse23 commented Oct 25, 2019

How often can you reproduce it?
Have

  • Always
  • Sometimes
  • Rarely
  • Unable
  • I didn’t try

Description:
AMD define doesn't work for dynamic import.

Steps to reproduce:

  • Given src below:
**
 * load single module
 * @param {string} moduleName module name or rel path as key
 * @returns {Promise} promise with module object
 */
export function loadModule( moduleName ) {
    /*
    if ( /few-button$/.test( moduleName ) ) {
        return Promise.resolve( FewButton );
    }
    */
    return import( moduleName );
}
  • Compile by rollup to amd mode.
  • At runtime, use stealJS, try to define a dependency in DSL. It will go through this code and try to load that dep.
  • The dep JS looks like:
define( [
          '//cdn.jsdelivr.net/npm/vue/dist/vue.js',
          'lib/httpVueLoader'
        ], ( Vue, httpVueLoader ) => {
...

In this practice, steal.js will go to a call stack which disabling define explicitly:
image

  • It will get error Error: define is not a function.
  1. Include a link to your project (Here)
  2. Detail the exact steps taken to produce the problem
  3. Include a gif if applicable; you can use LICEcap to make a gif: http://www.cockos.com/licecap/

Expected results:

  • May I get a better understanding to that?
  • Any possible workaround?
  • Possible to fix?

Environment:

Software Version
Steal version 2.2.4
Steal-tools version Not used
node -v 10.5.3
npm -v 6.4.1
Browser not use
Operating system windows
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