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

[1.3 beta] issue on global space inside local package. #5819

Closed
bySabi opened this issue Dec 16, 2015 · 7 comments
Closed

[1.3 beta] issue on global space inside local package. #5819

bySabi opened this issue Dec 16, 2015 · 7 comments
Assignees
Labels
confirmed We want to fix or implement it
Milestone

Comments

@bySabi
Copy link

bySabi commented Dec 16, 2015

I update a project from 1.2.1 to 1.3 beta0 and my local packages, more of then npm wrappers around jQuery plugins, can´t found jQuery or '$' global.
I create a minimal repo with a jQuery plugin on a local package for reproduction.
This example work fine on 1.2.1 even without add 'jquery' inside package. But is not the case with 1.3.
My impression it is a problem between global Meteor scope and IIFE that not find jQuery on window global object. Maybe when IIFE is called Meteor environment is not yet set??

This a test repo: https://github.com/bySabi/bug-on-1.3-beta0-with-jqueryplugin-package

@stubailo stubailo added this to the Release 1.3 milestone Dec 17, 2015
@avital
Copy link
Contributor

avital commented Dec 18, 2015

I ran your app on Meteor 1.3-modules-beta.0 and saw the following error in the console:

Uncaught TypeError: Cannot read property 'Gallery' of undefined

Then I ran it with Meteor 1.2.1 and got the same error.

Are you sure this repro demonstrates the problem you are hitting?

@bySabi
Copy link
Author

bySabi commented Dec 18, 2015

You are right @avital. This repo not fail! .. Sorry for that.
I update an App from 1.2.1 to 1.3 beta0 and I have many problems on the client side. All errors are related to global. Ex: jquery, $, module, my own global: 'App' are undefined.
I not isolate problem yet. Still looking

@avital
Copy link
Contributor

avital commented Dec 18, 2015

@stubailo told me that he also hit something similar. Maybe he'll find a repro as well. But let's keep looking, if this is a real problem.

@benjamn
Copy link
Contributor

benjamn commented Dec 19, 2015

Fixed in 1.3b1: #5788 (comment)

@benjamn benjamn closed this as completed Dec 19, 2015
@bySabi
Copy link
Author

bySabi commented Dec 19, 2015

@benjamn, still have problems with globals on Beta1. This time with ...

sacha_spin.js:43      Uncaught ReferenceError: module is not defined

You can reproduce it creating a clean project and add sacha:spin@2.3.1

@bySabi
Copy link
Author

bySabi commented Dec 19, 2015

I create a package globals

package.js

Package.describe({
  name: 'globals',
  version: '0.1.0',
});

Package.onUse(function(api) {
  api.addFiles('global.js');
  api.export('module');
});

global.js

var global = this;
var module = {};

exports.module = module;
global.module = module;

and this solve: sacha_spin.js:43 Uncaught ReferenceError: module is not defined

But now I have a new one:

ReferenceError: Spinner is not defined

@trusktr
Copy link
Contributor

trusktr commented Dec 26, 2015

Possible duplicates: #5870 #5886 #5868

avital added a commit that referenced this issue Jan 8, 2016
Prior to this change, linker’s package global variable scanning mechanism was
broken. All package global variables were exposed as full global variables.
This was due to calling `escope`’s `analyzeScope` function with `{sourceType:
"modules"}`.

While at it, fixed incorrect code that exposes `process` on the client. The
previous code seemed to work to work because we were exposing all package globals as
real globals.

Should fix #5870 and #5819
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed We want to fix or implement it
Projects
None yet
Development

No branches or pull requests

5 participants