-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Importing npm package causes error when compiling asserts in Webpack 4.x. Works just fine in Webpacker 3.x #1949
Comments
With ES2015 - |
Ah, found the issue. As mentioned here, adding: environment.loaders.delete('nodeModules') or indeed: const nodeModulesLoader = environment.loaders.get('nodeModules');
if (!Array.isArray(nodeModulesLoader.exclude)) {
nodeModulesLoader.exclude = (nodeModulesLoader.exclude == null)
? []
: [nodeModulesLoader.exclude];
}
nodeModulesLoader.exclude.push(/react-s-alert/); to |
There was a PR to add this to the docs, not sure why it was rejected: https://github.com/rails/webpacker/pull/1893/files?short_path=4ac32a7#diff-4ac32a78649ca5bdd8e0ba38b7006a1e |
Oh man, it would have saved me some hours if it had been. |
jakeNiemiec
added a commit
to jakeNiemiec/webpacker
that referenced
this issue
Jun 8, 2020
fixes rails/rails#35501 fixes rails#2131 fixes rails/rails#36278 fixes rails#2407 fixes rails#2114 fixes rails#1949 fixes rails#1865 fixes rails#1857
gauravtiwari
pushed a commit
that referenced
this issue
Jun 17, 2020
fixes rails/rails#35501 fixes #2131 fixes rails/rails#36278 fixes #2407 fixes #2114 fixes #1949 fixes #1865 fixes #1857
KingTiger001
added a commit
to KingTiger001/Rails-web-pack-project
that referenced
this issue
Jan 15, 2023
fixes rails/rails#35501 fixes rails/webpacker#2131 fixes rails/rails#36278 fixes rails/webpacker#2407 fixes rails/webpacker#2114 fixes rails/webpacker#1949 fixes rails/webpacker#1865 fixes rails/webpacker#1857
smartech7
pushed a commit
to smartech7/ruby-webpacker
that referenced
this issue
Aug 4, 2023
fixes rails/rails#35501 fixes rails/webpacker#2131 fixes rails/rails#36278 fixes rails/webpacker#2407 fixes rails/webpacker#2114 fixes rails/webpacker#1949 fixes rails/webpacker#1865 fixes rails/webpacker#1857
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I'm using the react-s-alert package and when I try to deploy my webpacker-based Rails/React app to production, the app is just a blank screen and I observe the error
TypeError: t is not a function - s-alert-tools.js:22
in the console.This is the specific file causing the error on GitHub.
Strangely, this only happens for Webpacker 4.x. With Webpacker 3.x everything works as expected.
Ruby: 2.6.0
Rails: 5.2.2
Webpacker: 4.0.0.rc.7
Yarn: 1.13.0
Steps to Reproduce:
rails new myapp
cd myapp
gem 'webpacker', '>= 4.0.x'
to the Gemfileyarn add @rails/webpacker@next
bundle
bundle exec rails webpacker:install
bundle exec rails webpacker:install:react
rails g controller site index
/app/views/layouts/application.html.erb
replace thejavascript_include_tag
with<%= javascript_pack_tag 'hello_react' %>
yarn add react-s-alert
app/javascript/packs/hello_react.jsx
add:import Alert from 'react-s-alert';
RAILS_ENV=production rake db:create db:migrate db:seed
rake secret
and copy the outputexport SECRET_KEY_BASE=output-of-rake-secret
export RAILS_SERVE_STATIC_FILES="true"
rake assets:precompile
RAILS_ENV=production rails s
TypeError: t is not a function
in the consoleIs this a bug in Webpacker? I'm reporting it here as the above steps work as expected using the latest 3.x release, but switching to Webpacker 4.x caused this error.
I'm stumped as to how to debug this any further and would appreciate any help.
The text was updated successfully, but these errors were encountered: