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

Wrong result of import after updating modules to 0.9.0 #33

Closed
SimonSimCity opened this issue Jun 28, 2017 · 18 comments
Closed

Wrong result of import after updating modules to 0.9.0 #33

SimonSimCity opened this issue Jun 28, 2017 · 18 comments

Comments

@SimonSimCity
Copy link

SimonSimCity commented Jun 28, 2017

I guess your extension here is incompatible with modules since v0.9.0. It's quite easy to reproduce. Here's a quick manual of how to do it. Install a plugin (like hwillson:stub-collections) into a fresh project (like described here: hwillson/meteor-stub-collections#17 (comment)). Run the project by calling meteor and you see, that it works as expected. In your console you see that the import returns

I20170628-11:34:13.452(4)? { add: [Function], stub: [Function], restore: [Function] }

It also returns this result after replacing ecmascript by your plugin while modules is on v0.8.2 or lower. But after updating this module the result changes into:

I20170628-11:36:28.382(4)? { default: { add: [Function], stub: [Function], restore: [Function] } }

If I now replace your plugin back with ecmascript while leaving modules in a version like v0.9.0 I get the expected first result again.

I suppose, this has something to do with your plugin being incompatible with the latest changes of the modules package ... or am I mistaken here?

@pbastowski
Copy link
Owner

I think you're right. I haven't been maintaining this plugin for a long time now, so, it is bound to have issues.

I would suggest using the ecmascript package instead, because the main real benefit from using my package was the integration with ng-annotate.

When I was still coding in angularjs I was using my ng2now library, available on npm, which largely removes the need for using ng-annotate and allows you to write code that looks like angular2.

Sorry I can't give you better news.

@SimonSimCity
Copy link
Author

SimonSimCity commented Jul 3, 2017

I've now solved it differently - you could also update your README.md if you want ...

Since this package doesn't seem to be maintained anymore, and running ng-annotate was it's only benefit over ecmascript, and the ng-annotate pacakge is discontinued by a babel plugin (as you can read in the README.md of the project https://github.com/olov/ng-annotate) I did this.

For anyone running into this, run the following commands:

meteor remove pbastowski:angular-babel
meteor add ecmascript
meteor npm install --save-dev babel-plugin-angularjs-annotate

And add the following lines to your package.json (as described here https://babeljs.io/docs/usage/babelrc/#use-via-package-json):

  "babel": {
    "plugins": ["angularjs-annotate"]
  },

It seems that Meteor ignores the file .babelrc, but takes into account the babel property in your package.json file. If you want more insight, read meteor/meteor#6351

I also want to encourage you to provide this as a drop-in replacement, since it is 😉 No drawbacks so far.

@aymericbouzy
Copy link

Thanks @SimonSimCity! I first had to remove all dependencies to pbastowski:angular-babel in my local packages : I had to replace all api.use("pbastowski:angular-babel") by api.use("ecmascript"). Just in case someone else does the same migration !

@aymericbouzy
Copy link

It's not working for me after all 😢 package angular depends on pbastowski:angular-babel ... @pbastowski, @SimonSimCity, any advice?

@aymericbouzy
Copy link

aymericbouzy commented Sep 7, 2017

Found a solution! According to https://guide.meteor.com/1.3-migration.html, I can remove my dependency on angular package by using angular npm module instead 🎉

EDIT : my codemod for including angular import when needed :

codemod -m --extensions js --exclude-paths node_modules,.meteor 'angular(\W*\.)' 'import ANGULAR from "ANGULAR"\n\nANGULAR\1'           

(then replace all ANGULAR by angular)

@pbastowski
Copy link
Owner

@aymericbouzy Yes, that's exactly what I was going to suggest :) I'm glad you found it!

@aymericbouzy
Copy link

Thanks : now I run into another issue :

=> Started proxy.                             
=> Meteor 1.5.2 is available. Update this project with 'meteor update'.
   Processing files with ecmascript (for...  /
/Users/aymericbouzy/Documents/dev/meteor/gofer/src/node_modules/babel-plugin-angularjs-annotate/babel-ng-annotate.js:4
const ngInject = require('./nginject');
^^^^^
=> Errors prevented startup:                  
   
   While processing files with ecmascript (for target web.browser):
   module.js:439:25: Use of const in strict mode.
   at Module._compile (module.js:439:25)
   at Object.Module._extensions..js (module.js:474:10)
   at Module.load (module.js:356:32)
   at Module.Mp.load
   (/Users/aymericbouzy/.meteor/packages/meteor-tool/.1.3.5_1.1jn55il++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/reify/node/runtime.js:16:23)
   at Function.Module._load (module.js:312:12)
   at Module.require (module.js:364:17)
   at require (module.js:380:17)
   at InputFile.<anonymous> (/tools/isobuild/compiler-plugin.js:356:12)
   at InputFile.require
   (/Users/aymericbouzy/.meteor/packages/meteor-tool/.1.3.5_1.1jn55il++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/isobuild/compiler-plugin.js:353:23)
   at reqMightThrow (packages/babel-compiler/babel-compiler.js:249:1)
   at req (packages/babel-compiler/babel-compiler.js:219:1)
   at packages/babel-compiler/babel-compiler.js:293:1
   at Array.forEach (native)
   at infer (packages/babel-compiler/babel-compiler.js:291:1)
   at BabelCompiler.BCp._inferHelper (packages/babel-compiler/babel-compiler.js:321:1)
   at BabelCompiler.BCp._inferFromPackageJson (packages/babel-compiler/babel-compiler.js:186:1)
   at BabelCompiler.BCp.inferExtraBabelOptions (packages/babel-compiler/babel-compiler.js:155:1)
   at BabelCompiler.BCp.processOneFileForTarget (packages/babel-compiler/babel-compiler.js:97:1)
   at BabelCompiler.<anonymous> (packages/babel-compiler/babel-compiler.js:21:1)
   at Array.forEach (native)
   at BabelCompiler.BCp.processFilesForTarget (packages/babel-compiler/babel-compiler.js:20:1)

Is it because I'm running Meteor 1.3.5.1 (Node 0.10.x ?) My issue is that I can't upgrade to Meteor 1.5 for now, but I still want to be able to use es6 syntax, especially modules. This project I have to maintain has so many outdated dependencies 😵

@SimonSimCity
Copy link
Author

@aymericbouzy wasn't ES2015 support actually introduced in Meteor 1.3 ..? Maybe it's something with babel, that it for some reason doesn't translate this module ... Don't know ... Maybe the step to Meteor 1.4 helps you.

@pbastowski
Copy link
Owner

@aymericbouzy Can you share your repo? I will try to help you.

@ananthavel
Copy link

ananthavel commented Sep 10, 2017

Hi,
I tried following commands,

meteor remove pbastowski:angular-babel
meteor add ecmascript
meteor npm install --save-dev babel-plugin-angularjs-annotate

$ meteor npm install --save-dev babel-plugin-angularjs-annotate
npm ERR! Linux 3.13.0-129-generic
npm ERR! argv "/home/xxx/.meteor/packages/meteor-tool/.1.4.1_1.c8r5vz++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/bin/node" "/home/xxx/.meteor/packages/meteor-tool/.1.4.1_1.c8r5vz++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/bin/npm" "install" "--save-dev" "babel-plugin-angularjs-annotate"
npm ERR! node v4.5.0
npm ERR! npm v3.10.6
npm ERR! file /home/xxx/workspace-meteor/proj-nam//package.json
npm ERR! code EJSONPARSE

npm ERR! Failed to parse json
npm ERR! Unexpected token 'b' at 20:2
npm ERR! "babel": {
npm ERR! ^
npm ERR! File: package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse

NPM Log:

0 info it worked if it ends with ok
1 verbose cli [ '/home/xxx/.meteor/packages/meteor-tool/.1.4.1_1.c8r5vz++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/bin/node',
1 verbose cli '/home/xxx/.meteor/packages/meteor-tool/.1.4.1_1.c8r5vz++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/bin/npm',
1 verbose cli 'install',
1 verbose cli '--save-dev',
1 verbose cli 'babel-plugin-angularjs-annotate' ]
2 info using npm@3.10.6
3 info using node@v4.5.0
4 silly loadCurrentTree Starting
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly rollbackFailedOptional Starting
8 silly rollbackFailedOptional Finishing
9 silly runTopLevelLifecycles Starting
10 silly runTopLevelLifecycles Finishing
11 silly install printInstalled
12 verbose stack Error: Failed to parse json
12 verbose stack Unexpected token 'b' at 20:2
12 verbose stack "babel": {
12 verbose stack ^
12 verbose stack at parseError (/home/ananth/.meteor/packages/meteor-tool/.1.4.1_1.c8r5vz++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/npm/node_modules/read-package-json/read-json.js:390:11)
12 verbose stack at parseJson (/home/ananth/.meteor/packages/meteor-tool/.1.4.1_1.c8r5vz++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/npm/node_modules/read-package-json/read-json.js:79:23)
12 verbose stack at /home/ananth/.meteor/packages/meteor-tool/.1.4.1_1.c8r5vz++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/npm/node_modules/read-package-json/read-json.js:48:5
12 verbose stack at /home/ananth/.meteor/packages/meteor-tool/.1.4.1_1.c8r5vz++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16
12 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
13 verbose cwd /home/ananth/workspace-meteor/projname
14 error Linux 3.13.0-129-generic
15 error argv "/home/ananth/.meteor/packages/meteor-tool/.1.4.1_1.c8r5vz++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/bin/node" "/home/ananth/.meteor/packages/meteor-tool/.1.4.1_1.c8r5vz++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/bin/npm" "install" "--save-dev" "babel-plugin-angularjs-annotate"
16 error node v4.5.0
17 error npm v3.10.6
18 error file package.json
19 error code EJSONPARSE
20 error Failed to parse json
20 error Unexpected token 'b' at 20:2
20 error "babel": {
20 error ^
21 error File: package.json
22 error Failed to parse package.json data.
22 error package.json must be actual JSON, not just JavaScript.
22 error
22 error This is not a bug in npm.
22 error Tell the package author to fix their package.json file. JSON.parse
23 verbose exit [ 1, true ]

Can you direct me, to resolve. As I have completed the development few months back, hoping to replace minimum workable solution.

Thanks
Ananth S

@pbastowski
Copy link
Owner

@ananthavel could you please post your package.json here? I think it may be missing a comma.

@ananthavel
Copy link

"name": "proj-name",
"private": true,
"scripts": {
"start": "meteor run"
},
"dependencies": {
"angular": "^1.6.0",
"angular-material": "^1.1.1",
"angular-meteor": "^1.3.11",
"angular-ui-router": "^0.3.2",
"babel-runtime": "^6.20.0",
"bootstrap-ui-datetime-picker": "^2.4.4",
"meteor-node-stubs": "^0.2.11",
"tether": "^1.4.0"
},
"devDependencies": {
"babel-plugin-angularjs-annotate": "^0.8.0"
}
"babel": {
"plugins": ["angularjs-annotate"]
}

@pbastowski
Copy link
Owner

@ananthavel add a comma just before the "babel" key

@ananthavel
Copy link

Thanks pbastowski, it solved my problem.
Ending in another error while running meteor. Will look for resolving.

@ananthavel
Copy link

Hi pbastowski,
Im ending in another issue after resolving the babel issue.

Error

Unable to resolve some modules:

“cordova/exec” in /home/ananth/workspace-meteor/proj-name/android/android/project/platform_www/cordova-js-src/platform.js
(os.linux.x86_64)
“cordova/channel” in
/home/ananth/workspace-meteor/proj-name/android/android/project/platform_www/cordova-js-src/platform.js (os.linux.x86_64)
“cordova/utils” in /home/ananth/workspace-meteor/proj-name/android/android/project/platform_www/cordova-js-src/exec.js
(os.linux.x86_64)
“cordova/android/promptbasednativeapi” in
/home/ananth/workspace-meteor/proj-name/android/android/project/platform_www/cordova-js-src/android/nativeapiprovider.js
(os.linux.x86_64)
“cordova/android/nativeapiprovider” in
/home/ananth/workspace-meteor/proj-name/android/android/project/platform_www/cordova-js-src/exec.js (os.linux.x86_64)
“cordova/base64” in /home/ananth/workspace-meteor/proj-name/android/android/project/platform_www/cordova-js-src/exec.js
(os.linux.x86_64)
“cordova/modulemapper” in
/home/ananth/workspace-meteor/proj-name/android/android/project/platform_www/cordova-js-src/platform.js (os.linux.x86_64)
“cordova/init” in /home/ananth/workspace-meteor/proj-name/android/android/project/platform_www/cordova.js
(os.linux.x86_64)

If you notice problems related to these missing modules, consider running:

meteor npm install --save cordova

W20170919-22:44:33.561(5.5)? (STDERR) /home/ananth/workspace-meteor/proj-name/android/android/project/cordova/node_modules/plist/examples/browser/index.html:1
W20170919-22:44:33.564(5.5)? (STDERR) (function (exports, require, module, __filename, __dirname) {
W20170919-22:44:33.565(5.5)? (STDERR) ^
W20170919-22:44:33.566(5.5)? (STDERR)
W20170919-22:44:33.567(5.5)? (STDERR) SyntaxError: Unexpected token <
W20170919-22:44:33.568(5.5)? (STDERR) at exports.runInThisContext (vm.js:53:16)
W20170919-22:44:33.569(5.5)? (STDERR) at Module._compile (module.js:373:25)
W20170919-22:44:33.570(5.5)? (STDERR) at Object.Module._extensions…js (module.js:416:10)
W20170919-22:44:33.571(5.5)? (STDERR) at Module.load (module.js:343:32)
W20170919-22:44:33.572(5.5)? (STDERR) at Function.Module._load (module.js:300:12)
W20170919-22:44:33.572(5.5)? (STDERR) at Module.require (module.js:353:17)
W20170919-22:44:33.573(5.5)? (STDERR) at require (internal/module.js:12:17)
W20170919-22:44:33.574(5.5)? (STDERR) at npmRequire (/home/ananth/workspace-meteor/proj-name/.meteor/local/build/programs/server/npm-require.js:133:10)
W20170919-22:44:33.575(5.5)? (STDERR) at Module.useNode (packages/modules-runtime.js:687:18)
W20170919-22:44:33.576(5.5)? (STDERR) at fileEvaluate (packages/modules-runtime.js:332:20)
=> Exited with code: 1
=> Your application is crashing. Waiting for file change.
Doing HTTP request: POST

Can you suggest me any idea?

Regards,
Ananth

@aymericbouzy
Copy link

If you read the error, it says :

If you notice problems related to these missing modules, consider running 

meteor npm install --save Cordova

Also, first copy paste your error on Google and try solving by yourself before asking for help.

  1. You'll learn more
  2. You'll become more independent
  3. You'll save other people's time
  4. They'll be more ready to help when you face a real issue

@leosco
Copy link

leosco commented Oct 25, 2017

@aymericbouzy the angular package on atmosphere has been totally deprecated for a while. If you check the legacy angular-meteor tutorials, you migrate all that to npm packages. I believe the only atmosphere package you should be using, after following @SimonSimCity 's directions, is angular-templates.

@SimonSimCity amazing work, bud. It truly is a seamless drop-in, and I'm so happy to have all the latest ecmascript support now without having to change my front-end. I stumbled across this because my async/await functions weren't working as expected in meteor and I was like "is something wrong with ecmascript?" then I realized I'm an angular-meteor dev and I haven't been using ecmascript this whole time. This thread has been a real life saver.

@aymericbouzy
Copy link

I have no knowledge at all of AngularJS, and I don't wish to start learning. The project I'm in charge of is simply in maintenance mode while we figure out how to rebuild a better solution.

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

5 participants