Giter Club home page Giter Club logo

esbuild-plugin-stimulus's People

Contributors

dependabot[bot] avatar intrepidd avatar zombiezen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

esbuild-plugin-stimulus's Issues

Add option to set custom controllers directories

Hello @zombiezen and first of all, many thanks for this plugin which is the missing piece to our esbuild + Stimulus "puzzle".

In our app we stimulus controller in many different directories,

  • sidecar Stimulus controllers for ViewComponent components in app/components/
  • generic components share by the 3 parts of our app in app/javascript/controllers/shared
  • components for specific part of our app in directories like app/javascript/controllers/shop and app/javascript/controllers/backoffice

Due to this, some controllers cannot be imported (those outside app/javascript/controllers) and some others are namespaced backoffice-- or shop-- while they should not be.

Is there a way to pass a list of base directories to esbuildand/or your plugin to specify directories without adding code the the plugin ? Or should the plugin be modified ?

If anyone at @levups could be of any help, let us know :)

No matching export

Given this directory layout:

foo.js
src/foo/controllers.js
src/foo/controllers/*
// foo.js
import 'src/foo/controllers'
// src/foo/controllers.js
import { controllers } from 'stimulus:./controllers';

I get the following error:

No matching export in "stimulus_ns:/.../app/javascript/src/foo/controllers" for import "controllers"

I've tried changing the name of controller.js to stimulus_controllers.js but that doesn't make a difference.

We have multiple scripts which are loading both their own controllers in the old webpack way as well as registering shared controllers.

I've also tried moving it down the foo.js like so but get the same error:

import { Application } from '@hotwired/stimulus';
import { controllers } from 'stimulus:./src/foo/controllers';

const application = Application.start();
application.load(controllers);
No matching export in "stimulus_ns:/.../app/javascript/src/foo/controllers" for import "controllers"

stimulus_ns entry in generated source map has absolute path

Hello
Thanks for the great plugin

I noticed the "stimulus_ns" entry in my generated source map had the absolute path of the Stimulus controllers folder. This meant on production I was leaking information about the directory structure of my server e.g.

"stimulus_ns:/home/myuser/railsapp/app/javascript/controllers"

My workaround:

I replaced the returned path in build.onResolve with

return {
  path: path.relative(process.cwd(), path.join(path.dirname(args.importer), sep)), //change from absolute to relative directory
  namespace,
};

and the resolveDir in build.onLoad with

return {
  contents,
  loader: 'js',
  resolveDir: path.join(process.cwd(), args.path), //change from relative to absolute directory
};

Hope that helps, not sure if it's the correct approach or desirable as a PR.

Handle nested controllers

Welcome to the hype :)

This plug-in doesn't recursively look through controller folders.

If you do several imports it works but the definitions are not prefixed with the namespace as expected

How about adding resursive lookup of controllers?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.