-
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
Allow pack files to be placed in subdirectories #201
Conversation
I think not considering sub-folders is intended, because I have no clue about Vue but e.g. for React this is totally fine. |
Thanks for your comment. I suppose that you assume a kind of single page application with a very few entry points. Under this assumption, organizing entry points using subdirectories seems an overdo. I personally, however, want to have a lot of entry points. I often create a small Vue component in order to fullfil a small functionality, which used to be done with jQuery. In such case, there are times to need a separate Suppose that we have This use case might not have been under consideration by the core team, but I think it is very important especially for Vue developers. |
I see your point, that you might have a requirement for subfolders in a huge app, where you have multiple areas like "admin" and "portal", each containing multiple pages and therefor entry points. But I'm still not sure if Webpacker should go for that case by default, but this decision has to be made by the core contributors. |
whats the downside of this pr? the So I think this pr enforces developers to keep the packs folder clean from anything but entry points, which I think is a good thing. |
@kuroda How about you just name space them within file name? For ex - Please correct me if I am assuming wrong? This is what we have in readme, // app/javascript/packs/calendar.js
require('calendar')
app/javascript/calendar/index.js // gets loaded by require('calendar')
app/javascript/calendar/components/grid.jsx
app/javascript/calendar/styles/grid.sass
app/javascript/calendar/models/month.js If you have multiple namespaces, just name space the pack/entry name - I guess this change will create some edge cases |
I like the idea of using actual directories for namespaces. Follows how we
do namespaces in the rest of a Rails app as well. Did you find any problems
with this change, Gaurav?
…On Wed, Apr 5, 2017 at 1:17 PM, Gaurav Tiwari ***@***.***> wrote:
@kuroda <https://github.com/kuroda> How about you just name space them
within file name? For ex - admin-new or portal-new . I am not sure, but
subdirectories seems redundant, when all we are keeping here are
packs/entries name, which is essentially going to be one per module or
bundle.
Please correct me if I am assuming wrong?
This is what we have in readme,
// app/javascript/packs/calendar.jsrequire('calendar')
app/javascript/calendar/index.js // gets loaded by require('calendar')
app/javascript/calendar/components/grid.jsx
app/javascript/calendar/styles/grid.sass
app/javascript/calendar/models/month.js
If you have multiple namespaces, just name space the pack/entry name -
admin-calendar.js, app-calendar.js.
I guess this change will create some edge cases
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#201 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAKtUVuf9OCIXSxX4DA-xWXaBbQJAT7ks5rs9qigaJpZM4MsZBM>
.
|
I think there are arguments for both sides, but I agree with @dhh it fits with Rails namespaces. And thinking of bigger apps I would prefer directories instead of @gauravtiwari suggestion as well. As an alternative option, how about only allowing one level of sub-directories by replacing the ** with a single * ? Just an idea, not sure if I like it. |
I don't like trying to second guess what's reasonable here. We're designing
for adults and they can decide for themselves. We should of course nudge
them in a good direction, but think we're already doing that.
…On Wed, Apr 5, 2017 at 3:54 PM, Ronny Haase ***@***.***> wrote:
I think there are arguments for both sides, but I agree with @dhh
<https://github.com/dhh> it fits with Rails namespaces. And thinking of
bigger apps I would prefer directories instead of @gauravtiwari
<https://github.com/gauravtiwari> suggestion as well.
As an alternative option, how about only allowing one level of
sub-directories by replacing the ** with a single * ? Just an idea, not
sure if I like it.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#201 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAKtVkfty_x4UE4HcWxuLoCuATa8yWNks5rs_-fgaJpZM4MsZBM>
.
|
Vue.js allows JS components to pick their template from an HTML element. If we have this code as import Vue from 'vue/dist/vue.esm'
document.addEventListener('DOMContentLoaded', () => {
new Vue({
el: "#app",
data: { name: "world" },
methods: {
changeName: function() {
this.name = "Alice"
}
}
})
}) then, you can use this component like this: <div id="app">
<p>Hello, {{ name }}</p>
<button v-on:click="changeName">Click me</button>
</div>
<%= javascript_pack_tag "hello_world" %> With this approach, we can introduce Vue.js to an existing Rails app without massive code change. I assume that this app has a lot of (hundreds of, maybe) pages which are organized using namespaces. In this circumstance, I don't want to see hundreds of JS files scattered in the |
…M error. After upgrading to 2.0, I was consistently running out of RAM when trying to run webpack. After some digging, I came across a comment on the webpack project that helped shed some light. webpack/webpack#1914 (comment) It seems that in PR 201 (rails#201), the `extensionGlob` was changed from `*{${paths.extensions.join(',')}}*` to `**/*{${paths.extensions.join(',')}}*` This change removes the `**/` in the extension and fixes my OOM issue. I am not sure about the ramifications for allowing pack files in subdirectories (the original intent of the PR that introduced the change). Maybe we need a comment or a flag when generating the configuration that will set it one way or the other?
With this commit, you can organize JavaScript files with namespaces.
For example: