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

Auto import dependencies #2494

Open
2 of 10 tasks
WTbohdano opened this issue Aug 23, 2024 · 4 comments
Open
2 of 10 tasks

Auto import dependencies #2494

WTbohdano opened this issue Aug 23, 2024 · 4 comments

Comments

@WTbohdano
Copy link

WTbohdano commented Aug 23, 2024

  • SystemJS Version: 6.8.3 | 6.15.1
  • Which library are you using?
    • system.js
    • s.js
    • system-node.cjs
  • Which extras are you using?
    • AMD extra
    • Named Exports
    • Named Register
    • Transform
    • Use Default
    • Global
    • Dynamic Import Maps
  • Are you using any custom hooks? No

Question

I have an issue with auto import logic. I have storybook which is configured to a library type system. It automatically loads the systemjs like output bundle.
SystemJS has document readyState check, in case loading it would add module to a autoImportCandidates. Later on its used in a instantiate logic, so it skip module load. Because of it, getRegister is not executed and last register is not reset. It leads to a wrong dependency resolution of the first dependency of a module.

Example:

System.register(['react', 'react-dom'],  () => {...})

First module dependency react has a dependency ['react', 'react-dom']

Workaround

Im hacking auto import logic, manually calling getRegister to reset lastRegister

const SystemJSPrototype = System.constructor.prototype;
const register = SystemJSPrototype.register;

SystemJSPrototype.register = function() {
  register.apply(this, arguments);

  if (document.readyState === 'loading') {
    SystemJSPrototype.getRegister();
  }
}

Sumarry

Is it expected behavior ?
I guess lastRegister should be reseted on auto imported modules as well. It could be done right once autoImportCandidates is reseted.

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

2 participants
@WTbohdano and others