Я делаю Rails project с помощью Browserify. Загрузочный Javascript загружается с помощью браузера.Browserify-shim Полтергейст/Phantom.JS проблемы с строгим режимом
Когда я запускаю свой проект и смотрю его в Firefox, все в порядке. Однако, когда я тестирую его через Полтергейст (или просто запустить его с PhantomJS 2.1.1), возникает ошибка:
Capybara::Poltergeist::JavascriptError:
One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details).
ReferenceError: Strict mode forbids implicit creation of global property 'jQuery'
ReferenceError: Strict mode forbids implicit creation of global property 'jQuery'
at http://127.0.0.1:47269/assets/application-038b5f3da112b67153daa218adfed54030ee9e0085fd9586c0bb13fa320b830e.js:12
Вот линия в вопросе:
;jQuery = global.jQuery = require("jquery");
Который, мне , выглядит как линия прокладок для jQuery (после него есть код bootstrap.js).
Вот мой package.json:
{
"name": "billy-bones-rails",
"version": "0.0.1",
"description": "Billy-bones-rails asset package",
"main": "index.js",
"directories": {
"doc": "doc",
"test": "test"
},
"scripts": {
"bundle-js": "./node_modules/.bin/browserify app/assets/javascripts/index.js -o app/assets/javascripts/bundle.js",
"watch-js": "./node_modules/.bin/watchify app/assets/javascripts/index.js -o app/assets/javascripts/bundle.js -d -v"
},
"repository": {
"type": "git",
"url": "git+https://github.com/art-solopov/billy-bones-rails.git"
},
"author": "Artemiy Solopov",
"license": "MIT",
"bugs": {
"url": "https://github.com/art-solopov/billy-bones-rails/issues"
},
"homepage": "https://github.com/art-solopov/billy-bones-rails#readme",
"dependencies": {
"babel-cli": "^6.8.0",
"babel-preset-es2015": "^6.6.0",
"babelify": "^7.3.0",
"bootstrap": "^3.3.6",
"browserify": "^13.0.0",
"browserify-shim": "^3.8.12",
"jquery": "^2.2.2",
"normalize.css": "^4.0.0",
"watchify": "^3.7.0"
},
"browser": {
"bootstrap": "./node_modules/bootstrap/dist/js/bootstrap.js"
},
"browserify": {
"transform": [
"browserify-shim",
[
"babelify",
{
"presets": "es2015"
}
]
]
},
"browserify-shim": {
"bootstrap": {
"depends": [
"jquery:jQuery"
]
}
}
}
Могу ли я сделать что-нибудь с этой ошибкой вне отключения полтергейст отчеты об ошибках?
P. S. Следует отметить, что я могу только воспроизвести эту ошибку, используя PhantomJS 2.1.1. В Firefox (46 и 48), Chromium и PhantomJS 1.9.0 нет ошибок.