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

fix: remove vestigial dependency #6219

Merged
merged 1 commit into from
Jun 17, 2022

Conversation

BeksOmega
Copy link
Collaborator

@BeksOmega BeksOmega commented Jun 15, 2022

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide
  • I ran npm run format and npm run lint

The details

Resolves

Hopefully fixes problems with message dependencies we ran into in samples.

Proposed Changes

Removes the vestigially Blockly dependency from the message wrappers.

Behavior Before Change

The Blockly module could not be resolved.

Behavior After Change

No need to resolve any modules hopefully.

Reason for Changes

Getting the messages to actually work.

Test Coverage

I tested manually removing the dependencies in the node_modules of some plugins in samples, and that seemed to fix things.

I also tried linking to field-bitmap and running npm run predeploy before and after this change, and the changes in this PR seemed to fix the problem.

Documentation

Additional Information

@BeksOmega BeksOmega requested a review from maribethb June 15, 2022 22:29
@BeksOmega BeksOmega marked this pull request as ready for review June 15, 2022 22:35
@BeksOmega BeksOmega requested a review from a team as a code owner June 15, 2022 22:35
@maribethb maribethb requested a review from cpcallen June 15, 2022 22:45
Copy link
Contributor

@cpcallen cpcallen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be fine:

  • The AMD and CJS wrapper entry points (and the body of the wrapped message files) do not depend on Blockly so have no need to require it.
  • While the browser entry point does depends on Blockly, it expect it to have been pre-loaded via <script>, so removing it here has no effect on the generated stanza.

I am interested in in what the problem you encountered in blockly-samples was, though. Was it somehow caused by #6210? It looks to me like the real issue here is that 'Blockly' is not the name of a file that can be loaded, that changing it to './blockly_compressed.js' (or one of the wrappers thereof) would have worked equally well (albeit being, as noted above, unnecessary).

@BeksOmega
Copy link
Collaborator Author

I am interested in in what the problem you encountered in blockly-samples was, though.

Oh yeah whoops, forgot to post. I was getting this error when running npm run predeploy

ERROR in ./node_modules/blockly/msg/en.js 
Module not found: Error: Can't resolve 'Blockly' in '/usr/local/google/home/bwestberg/Dev/blockly-samples/plugins/typed-variable-modal/node_modules/blockly/msg'
resolve 'Blockly' in '/usr/local/google/home/bwestberg/Dev/blockly-samples/plugins/typed-variable-modal/node_modules/blockly/msg'
  Parsed request is a module
  using description file: /usr/local/google/home/bwestberg/Dev/blockly-samples/plugins/typed-variable-modal/node_modules/blockly/package.json (relative path: ./msg)
    resolve as module
      /usr/local/google/home/bwestberg/Dev/blockly-samples/plugins/typed-variable-modal/node_modules/blockly/msg/node_modules doesn't exist or is not a directory
      looking for modules in /usr/local/google/home/bwestberg/Dev/blockly-samples/plugins/typed-variable-modal/node_modules/blockly/node_modules
        single file module
          using description file: /usr/local/google/home/bwestberg/Dev/blockly-samples/plugins/typed-variable-modal/node_modules/blockly/package.json (relative path: ./node_modules/Blockly)
            no extension
              /usr/local/google/home/bwestberg/Dev/blockly-samples/plugins/typed-variable-modal/node_modules/blockly/node_modules/Blockly doesn't exist
            .js
              /usr/local/google/home/bwestberg/Dev/blockly-samples/plugins/typed-variable-modal/node_modules/blockly/node_modules/Blockly.js doesn't exist
        /usr/local/google/home/bwestberg/Dev/blockly-samples/plugins/typed-variable-modal/node_modules/blockly/node_modules/Blockly doesn't exist
      /usr/local/google/home/bwestberg/Dev/blockly-samples/plugins/typed-variable-modal/node_modules/node_modules doesn't exist or is not a directory
      looking for modules in /usr/local/google/home/bwestberg/Dev/blockly-samples/plugins/typed-variable-modal/node_modules
        single file module
          using description file: /usr/local/google/home/bwestberg/Dev/blockly-samples/plugins/typed-variable-modal/package.json (relative path: ./node_modules/Blockly)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /usr/local/google/home/bwestberg/Dev/blockly-samples/plugins/typed-variable-modal/node_modules/Blockly doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /usr/local/google/home/bwestberg/Dev/blockly-samples/plugins/typed-variable-modal/node_modules/Blockly.js doesn't exist
        /usr/local/google/home/bwestberg/Dev/blockly-samples/plugins/typed-variable-modal/node_modules/Blockly doesn't exist
      /usr/local/google/home/bwestberg/Dev/blockly-samples/plugins/node_modules doesn't exist or is not a directory
      looking for modules in /usr/local/google/home/bwestberg/Dev/blockly-samples/node_modules
        single file module
          using description file: /usr/local/google/home/bwestberg/Dev/blockly-samples/package.json (relative path: ./node_modules/Blockly)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /usr/local/google/home/bwestberg/Dev/blockly-samples/node_modules/Blockly doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /usr/local/google/home/bwestberg/Dev/blockly-samples/node_modules/Blockly.js doesn't exist
        /usr/local/google/home/bwestberg/Dev/blockly-samples/node_modules/Blockly doesn't exist
      /usr/local/google/home/bwestberg/Dev/node_modules doesn't exist or is not a directory
      /usr/local/google/home/bwestberg/node_modules doesn't exist or is not a directory
      /usr/local/google/home/node_modules doesn't exist or is not a directory
      /usr/local/google/node_modules doesn't exist or is not a directory
      /usr/local/node_modules doesn't exist or is not a directory
      /usr/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
 @ ./node_modules/blockly/browser.js
 @ ./node_modules/blockly/index.js
 @ ./test/index.js 11:0-35 34:20-65 40:18-32

Was it somehow caused by #6210?

I'm honestly not sure. I tried to manually change the message wrappers to use define(['Blockly', '../core'], factory()) as well, which is what I imagine they looked like previously, and I got the same error. So this makes me think it was broken before.

However, Johnny just got a similar error, which was not happening before. Which makes me think it was working before.

But also, he's making a React app, so the AMD section of the wrapper shouldn't be affecting what he's doing. So I want to dig into that more before merging this.

@cpcallen
Copy link
Contributor

So I want to dig into that more before merging this.

Sensible enough, but just to be clear: I think this PR is fine on its own merits and can be merged whenever you like; I just think it's worth understanding what was broken (and for how long, and if for long how we avoided noticing until now) for the purposes of avoiding the same mistake(s) in future.

@BeksOmega
Copy link
Collaborator Author

So I checked out the v8.0.0 tag and before the amd definition would be define(['../core'], factory()), not define(['Blockly', '../core'], factory()) so that explains why my manual test failed.

I tested manually adding this fix (define([], factory())) to the react-demo and that fixed the problem that Johnny found. I still don't understand why React hits the amd module definition, but I guess it does.

So I'm cool putting this in now.

@BeksOmega BeksOmega merged commit 334956b into google:develop Jun 17, 2022
@cpcallen
Copy link
Contributor

I still don't understand why React hits the amd module definition, but I guess it does.

React probably (depends on something that)* depends on an AMD loader like RequireJS.

maribethb pushed a commit to maribethb/blockly that referenced this pull request Jul 27, 2022
@BeksOmega BeksOmega deleted the fix/msg-dependencies branch October 4, 2022 18:13
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

Successfully merging this pull request may close these issues.

3 participants