mit-cml/blockly-plugins

Name problems

Opened this issue · 6 comments

Hi,
I tried to add this plugin in my Blockly soft, but I add many errors:

  • LexicalVariables is not exported, so VSCode asked for 'LexicalVariablesPlugin' use
  • blockly core problem:
    Module not found: Error: Can't resolve 'blockly/core' in 'F:\Logiciels\Arduino_graphique\µcBlockly\node_modules@mit-app-inventor\blockly-block-lexical-variables\src'
    Did you mean 'core-browser.js'?
    BREAKING CHANGE: The request 'blockly/core' failed to resolve only because it was resolved as fully specified
    (probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '.mjs' file, or a '.js' file where the package.json contains '"type": "module"').
    The extension in the request is mandatory for it to be fully specified.
    Add the extension to the request.

Thanks for your help.

Thanks for pointing out the issues, Seb. I'm in the process of updating the plugin (and it's documentation). I plan to have the new version fixed within a couple of days, but I can't guarantee that. If you can't wait for that, I might suggest trying to use version 1.0.0. instead.

@SebCanet, All that you should need to do is change how you import and reference the plugin (in your code) to something like the following:

import {LexicalVariablesPlugin} from '@mit-app-inventor/blockly-block-lexical-variables';
...
const workspace = Blockly.inject(...);
...
// Load lexical variable plugin
LexicalVariablesPlugin.init(workspace);

I've updated the README file and the Lexical Block Demo code to reflect this.

Thanks, but in your demo there are a lot of dependencies problem. Or if I update all dependencies webpack has problem like this:

[webpack-cli] Failed to load 'K:\lexical-variable-demo-main\webpack.config.js' config
[webpack-cli] Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
 - options[0] has an unknown property 'to'. These properties are valid:
   object { patterns, options? }

Thanks for your help.

@SebCanet I'm not sure what your installation and build process for the demo was but I'll guess that you ran npm install, saw a bunch of error message and decided to update a bunch of packages. One of those packages was probably Webpack and that version of Webpack doesn't like the current webpack.config.js file in the repo. However, I actually use npm install --legacy-peer-deps to do the install step. I've updated the README file to say that.

Let me know if your attempt to install and run the demo still fails after using npm install --legacy-peer-deps.

At some point I might try to update to a more current set of dependencies, but that can get a little complicated and I've holding off on that. You are more than welcome to try and do that and submit a PR ;-). It's possible that you've already done most of the work and all you need to do is change the CopyPlugin part sof the webpack.config.js file to reflect it's latest syntax, which, according to its current documentation, looks like:

new CopyPlugin({
  patterns: [
     { from: "source", to: "dest" },
     { from: "other", to: "public" },
   ],
}),

Thanks, I would have never guess for the --legacy-deps...
Now I will try your plugin and see if it could be useful to my project. My goal is to mime C and have local#global variable, and also automatic typing for variable.

About your plugin, to make it work with latest version of all dependencies here's the plugin section in webpack.config.js as you explained earlier:

    plugins: [
        new webpack.optimize.ModuleConcatenationPlugin(),
        new CopyPlugin({
		  patterns: [
			 { from: path.resolve(__dirname, './node_modules/blockly/media'), to :"path.resolve(__dirname, 'docs/media')" },
			 { from: path.resolve(__dirname, 'public'), to: path.resolve(__dirname, 'docs') },
		   ],
		}),
    ],

But with an exact copy of the demo repo, or with dependencies updates, I have error message:

WARNING in ./node_modules/blockly/blockly_compressed.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'K:\lexical-variable-demo-main\node_modules\blockly\src\com\google\javascript\jscomp\js\util\owns.js' file: Error: ENOENT: no such file or directory, open 'K:\lexical-variable-demo-main\node_modules\blockly\src\com\google\javascript\jscomp\js\util\owns.js'
 @ ./node_modules/blockly/javascript_compressed.js
 @ ./node_modules/blockly/javascript.js
 @ ./src/index.js 26:0-55 42:21-56

Not sure the problem can be...

Thanks, I would have never guess for the --legacy-deps...

The npn install command will actually suggest that flag to you, but it's easy to miss it in the barrage of error messages that is prints out.

Now I will try your plugin and see if it could be useful to my project. My goal is to mime C and have local#global variable, and also automatic typing for variable.

That sounds great! If you think that you might want to define your own blocks using the fields in the plugin, let me know. I am intending to make that significantly simpler to do in the next major version of the plugin. That said, it might be possible to just redefine the existing blocks with small tweaks for your use.

But with an exact copy of the demo repo, or with dependencies updates, I have error message:
WARNING in ./node_modules/blockly/blockly_compressed.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from ...

You can safely ignore warnings about missing source map files, but if you have any errors that prevent building or running the demo, let me know. It all works for me, so we would have to figure out what is different for you.