Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-37006

Improved importing/requiring of modules across bundles

    • 1.0-m12, 1.0-pre-beta-1, 1.0-beta-1

      E.g. to accommodate the how we need control over how react and react-dom are loaded.

      tfennelly assigning to you for now but I intend to reach out tomorrow so we can work this together. We discussed a workaround for this last week but I was not successful after following the steps you'd provided. Could be something I've missed though. If it's not, let's try to fix together, with my final task being to do a write-up in a wiki about the steps needed to work around this problem.

      Steps followed:

      1. Add 'react-addons-css-transition-group' to init.jsx in blueocean-web
      2. In js-extensions/@jenkins-cd/subs/extensions-bundle.js, update the createBundle function near the end
      3. Build a new js-extensions
      4. npm install new js-extensions in blueocean-web and blueocean-personalization
      5. Re-run gulp bundle for both modules

          [JENKINS-37006] Improved importing/requiring of modules across bundles

          Cliff Meyers added a comment - - edited

          feature branch / diff that shows changes made so far:
          https://github.com/jenkinsci/blueocean-plugin/compare/feature/JENKINS-35840-35781-more-favoriting...feature/JENKINS-37007-favorites-animations

          Please note that checking out this code and running as-is won't work since a new js-extensions hasn't been published. I had been building and manually npm installing it in my local testing but it did not resolve the error.

          Cliff Meyers added a comment - - edited feature branch / diff that shows changes made so far: https://github.com/jenkinsci/blueocean-plugin/compare/feature/JENKINS-35840-35781-more-favoriting...feature/JENKINS-37007-favorites-animations Please note that checking out this code and running as-is won't work since a new js-extensions hasn't been published. I had been building and manually npm installing it in my local testing but it did not resolve the error.

          Michael Neale added a comment -

          Is this the duplicate react instances? Is there a bundling of a version of react due to a version change of a transitive dependency? A missin extDep entry?

          Michael Neale added a comment - Is this the duplicate react instances? Is there a bundling of a version of react due to a version change of a transitive dependency? A missin extDep entry?

          Cliff Meyers added a comment -

          Yes, same old error. From discussions w/ Tom, the extDep thing won't actually resolve this issue. We are adding a new dep which depends on React, and I think that it's getting bundled with the personalization module instead of being provided by blueocean-web. Tom said he'd have a look in the morning tomorrow, and when I'm online we'll touch base and get this sorted. If there's a process to document, I will make sure we put it somewhere.

          Cliff Meyers added a comment - Yes, same old error. From discussions w/ Tom, the extDep thing won't actually resolve this issue. We are adding a new dep which depends on React, and I think that it's getting bundled with the personalization module instead of being provided by blueocean-web. Tom said he'd have a look in the morning tomorrow, and when I'm online we'll touch base and get this sorted. If there's a process to document, I will make sure we put it somewhere.

          Tom FENNELLY added a comment -

          Hey Cliff ... is there a way we can create a test branch that breaks for this? I was going to try create one myself from the diff link you provided, but probably no point.

          Tom FENNELLY added a comment - Hey Cliff ... is there a way we can create a test branch that breaks for this? I was going to try create one myself from the diff link you provided, but probably no point.

          Michael Neale added a comment -

          tfennelly is this related to #JENKINS-35727 at all?

          Michael Neale added a comment - tfennelly is this related to # JENKINS-35727 at all?

          Tom FENNELLY added a comment -

          michaelneale yep, same thing. I'll close the other because I have my branches named after this one.

          Tom FENNELLY added a comment - michaelneale yep, same thing. I'll close the other because I have my branches named after this one.

          Tom FENNELLY added a comment - - edited

          PR: https://github.com/jenkinsci/js-builder/pull/5

          Still more to do ... in js-builder and in js-modules

          Tom FENNELLY added a comment - - edited PR: https://github.com/jenkinsci/js-builder/pull/5 Still more to do ... in js-builder and in js-modules

          James Dumay added a comment -

          tfennelly nice one BTW

          James Dumay added a comment - tfennelly nice one BTW

          Code changed in jenkins
          User: Tom Fennelly
          Path:
          gulpfile.js
          index.js
          internal/adjunctexternal.js
          internal/bundlegen.js
          internal/dependecies.js
          internal/maven.js
          internal/pipeline-transforms/buffered-text-accumulator-transform.js
          internal/pipeline-transforms/require-stub-transform.js
          internal/templates/entry-module.hbs
          internal/templates/export-module.hbs
          internal/templates/index.js
          package.json
          spec/adjunctexternal-spec.js
          spec/dependencies-spec.js
          spec/index-spec.js
          spec/modules/module1.js
          spec/modules/module2.js
          spec/modules/module3.js
          spec/modules/module4.js
          spec/modules/module5.js
          spec/modules/module6.js
          spec/modules/module7.js
          spec/modules/module8.js
          spec/modules/module9.js
          spec/paths-spec.js
          spec/require-stub-transform-spec.js
          http://jenkins-ci.org/commit/blueocean-js-builder/12e89446866500705522b76774b507fcf04dc94b
          Log:
          JENKINS-37006 Change bundle generation to map/import via bundle entry rewriting (#5)

          • refactor bundle generation code from index.js to internal/bundlegen.js
          • bundle map entry stub rewriting
          • Revert use of --ignore browserify option ... no use to us

          ... because it puts in one bundle map entry for all ignored modules (when there are multiple of them), pointing require at the same map entry for them all ... that's no use to us as we need a stub for each module

          • Enhance require-stub-transform to do module pruning

          ... after mappings have left modules unused

          • No need to rewrite module source when bundle mpa entry already removed (unused)
          • throw new Error
          • don't apply imports on "--no-imports"
          • Added warning for duplicate require mappings
          • rename withExternalModuleMapping to import

          and deprcated withExternalModuleMapping

          • Add export dependency builder code

          .. still need to use that in the generated bundle

          • Use a handlebars template to transform/wrap the entry module
          • export-module.hbs handlebars template
          • dependency exports
          • Updates to reflect changes in js-modules to handle version ranges etc
          • Mode tweaks to get bundling working with new module loading
          • require-stub-transform cleanups
          • bundle as to use a ModuleSpec
          • Fixed dep export when no imports
          • Added postBundle listener support
          • Only allow global exports when there's one bundle being generated
          • Remerge Cliff's changes for .babelrc
          • Better import message
          • Remove dependency on window-handle
          • Added node_module to moduleDef
          • post transform map of fullPaths to ids
          • 36-beta25
          • Readded the --full-paths option
          • nodeModulesRelPath function
          • Support for import aliases
          • Version updates for 0.0.37 release

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Tom Fennelly Path: gulpfile.js index.js internal/adjunctexternal.js internal/bundlegen.js internal/dependecies.js internal/maven.js internal/pipeline-transforms/buffered-text-accumulator-transform.js internal/pipeline-transforms/require-stub-transform.js internal/templates/entry-module.hbs internal/templates/export-module.hbs internal/templates/index.js package.json spec/adjunctexternal-spec.js spec/dependencies-spec.js spec/index-spec.js spec/modules/module1.js spec/modules/module2.js spec/modules/module3.js spec/modules/module4.js spec/modules/module5.js spec/modules/module6.js spec/modules/module7.js spec/modules/module8.js spec/modules/module9.js spec/paths-spec.js spec/require-stub-transform-spec.js http://jenkins-ci.org/commit/blueocean-js-builder/12e89446866500705522b76774b507fcf04dc94b Log: JENKINS-37006 Change bundle generation to map/import via bundle entry rewriting (#5) refactor bundle generation code from index.js to internal/bundlegen.js bundle map entry stub rewriting Revert use of --ignore browserify option ... no use to us ... because it puts in one bundle map entry for all ignored modules (when there are multiple of them), pointing require at the same map entry for them all ... that's no use to us as we need a stub for each module Enhance require-stub-transform to do module pruning ... after mappings have left modules unused No need to rewrite module source when bundle mpa entry already removed (unused) throw new Error don't apply imports on "--no-imports" Added warning for duplicate require mappings rename withExternalModuleMapping to import and deprcated withExternalModuleMapping Add export dependency builder code .. still need to use that in the generated bundle Use a handlebars template to transform/wrap the entry module export-module.hbs handlebars template dependency exports Updates to reflect changes in js-modules to handle version ranges etc Mode tweaks to get bundling working with new module loading require-stub-transform cleanups bundle as to use a ModuleSpec Fixed dep export when no imports Added postBundle listener support Only allow global exports when there's one bundle being generated Remerge Cliff's changes for .babelrc Better import message Remove dependency on window-handle Added node_module to moduleDef post transform map of fullPaths to ids 36-beta25 Readded the --full-paths option nodeModulesRelPath function Support for import aliases Version updates for 0.0.37 release

            tfennelly Tom FENNELLY
            cliffmeyers Cliff Meyers
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: