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

Add src/index.dev.js and src/index.dev.js (app entrypoints) #325

Merged
merged 12 commits into from
Mar 13, 2023
Merged

Conversation

Raruto
Copy link
Collaborator

@Raruto Raruto commented Feb 9, 2023

Motivation

Reduce nesting level of these files and make it more clear which is the entry point for the development or the production environment:

Before

.
├── config.js
└── src/
    ├── app/
    │   ├── dev/
    │   │   └── index.js
    │   └── main.js
    └── index.html

After

.
├── config.js
└── src/
    ├── index.dev.js
    ├── index.html
    └── index.prod.js

List of changes

  • move src/app/main.js into src/index.prod.js
  • move src/app/dev/index.js into src/index.dev.js
  • update gulp task browserify:app accordingly
  • refactor function devConfig() within config.template.js
    • remove deprecated event listener ProjectsRegistry~createProject within config.template.js (ref: #320)
    • remove deprecated event listener ProjectsRegistry~setCurrentProject within config.template.js (ref: #320)
    • add new event listener ApplicationService~initConfig in order to override initConfig.group.vendorkeys and initConfig.group.plugins variables while developing
  • add window.g3wsdk.info()in order to automatically print some debug info within developer console (ref: #124)

Additional notes

  • move the following import at the top of src/app/api.js in order to avoid a circular dependency caused by early inclusion of src/index.dev.js compared to src/app/dev/index.js in the app execution flow

    import ApplicationService from 'services/application';
  • move the following import from src/app/main.js into src/deprecated.js (related to: #44)

    import "regenerator-runtime";
  • move the following import from src/app/main.js into a new file src/globals.js (related to #71)

    window.g3wsdk = require('app/api');
  • add a new constant FONT_AWESOME_ICONS within src/app/constant.js (just to reduce the filesize of index.prod.js)

  • add documentation @type within src/app/constant.js

How to test

  1. Update the devConfig section within your config.js
  devConfig: function() {
    g3wsdk.core.ApplicationService.once('ready', () => { });
    g3wsdk.core.ApplicationService.once('initconfig', () => {
      initConfig.group.vendorkeys = Object.assign(initConfig.group.vendorkeys || {}, G3W_KEYS);
      initConfig.group.plugins    = Object.assign(initConfig.group.plugins || {}, G3W_PLUGINS.reduce((a, v) => ({ ...a, [v]: { ...initConfig.group.plugins[v], gid: initConfig.group.initproject, baseUrl: initConfig.staticurl }}), {}));
    });
    g3wsdk.gui.GUI.once('ready', () => { console.log('ready'); });
  }
  1. Run npm run dev in order to test dev entrypoint (ref index.dev.js)
  2. Run npm run build in order to test production entrypoint (ref index.prod.js)

What to test

  • in the development environment check that the following variables are set correctly

    • initConfig.group.vendorkeys (and the related local G3W_KEYS overrides are loaded correctly)
    • initConfig.group.plugins (and the related locally developed G3W_PLUGINS are loaded correctly)
  • in the production environment make sure the following file is not included in the generated bundle:

    • config.js
  • in both environments check (as far as possible) that no new circular references have been created (ie: static imports returning undefined objects)


Closes: #89
Closes: #124

- move `src/app/main.js` into `src/index.prod.js`
- move `src/app/dev/index.js` into `src/index.dev.js`
- update gulp task `browserify:app` accordingly
- move `import ApplicationService from 'services/application';` on top of `src/app/api.js` to avoid a circular dependency caused by early inclusion of `src/index.dev.js` compared to `src/app /dev/index.js` in the app execution flow
- move `import "regenerator-runtime";` into `src/deprecated.js`
- new file  `src/globals.js` (ref: `window.g3wsdk`)
- new constant value `FONT_AWESOME_ICONS` within `src/app/constant.js`
- improve documentation for `src/app/constant.js` (ref: `@type`)
@Raruto Raruto added docs Improvements or additions to documentation config Anything related to configuration files refactoring Anything which could result in a API change labels Feb 9, 2023
@Raruto Raruto added this to the v3.8 milestone Feb 9, 2023
- remove deprecated event listener `ProjectsRegistry~createProject`
- remove deprecated event listener `ProjectsRegistry~setCurrentProject`
- add new event listener `ApplicationService~initConfig` in order to override `initConfig.group.vendorkeys` and `initConfig.group.plugins` variables while developing
@Raruto Raruto changed the title Add src/index.dev.js and src/index.dev.js (app entrypoints) Add src/index.dev.js and src/index.dev.js (app.min.js entrypoints) Feb 9, 2023
@Raruto Raruto marked this pull request as ready for review February 9, 2023 11:09
@Raruto Raruto changed the title Add src/index.dev.js and src/index.dev.js (app.min.js entrypoints) Add src/index.dev.js and src/index.dev.js (app entrypoints) Feb 9, 2023
src/app/api.js Outdated Show resolved Hide resolved
@Raruto
Copy link
Collaborator Author

Raruto commented Mar 7, 2023

@volterra79 same as #309, when you have a some time 🧭, let me know if we are ready to merge it.

@volterra79 volterra79 self-requested a review March 13, 2023 08:43
gulpfile.js Show resolved Hide resolved
@volterra79 volterra79 merged commit 6718e22 into dev Mar 13, 2023
@volterra79 volterra79 deleted the dev-index branch March 13, 2023 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config Anything related to configuration files docs Improvements or additions to documentation refactoring Anything which could result in a API change
Projects
None yet
2 participants