> On Jul 4, 2024, at 9:16 PM, Michael Morris <tendo...@gmail.com> wrote:
> On Wed, Jul 3, 2024 at 11:11 PM Mike Schinkel <m...@newclarity.net 
> <mailto:m...@newclarity.net>> wrote:
> So I've had more time to mull this over, and some research, and I think I 
> have an approach.
> 
> First, instead of 'import', use 'require_module'.  The parsing rules for 
> require_module differ from require how the file is parsed, a subject for 
> another time.  Also, it's parallel to what is to follow.

+1 

> Speaking of new functions, let's start with these
> 
>   spl_set_include_ini_map('importmap.ini');
>   spl_set_include_json_map('importmap.json")

Those are a mouthful! 

> The json file is pretty much identical to the JavaScript importmaps. The ini 
> file looks like this
> 
>   root = "/absolute/path/to/application/root"
> 
>   [imports]
>   square = "./path/to/square.js"
>   circle = "./path/to/circle.js"
>   other/ = "./path/to/other/"
> 
>   [scopes]
>   \A[square] = './path/to/square/in/namespace/A/a.js'

I assume rather than `.js` you mean `.php` files in your example?

Also, I am not following how these imports and scopes will relate to the actual 
PHP code that would be affected/using packages.

> Whichever format is used is a matter of personal preference. The file can be, 
> and likely should be, written by composer or some future package manager.

Part of me likes the flexibility of two formats. The other more pragmatic part 
of me says stick with one format for fewer related bugs and to reduce the 
effort to support it for internal code and by 3rd parties.

Unless it can be fully cached by opcache I would think it would need to be the 
format that can be parsed the fastest, which could be binary like a Protobuf 
file.

> The root attribute in the map sets the root for all relative paths given in 
> the map.

Are you saying that a publisher of a package would need to write the absolute 
path to their `importmap.*` file. How will that work?  Even for a bespoke app 
Composer may not have enough access to the server to know this, and 3rd party 
packages will definitely not know it for their users. At least I don't think so.

Also, at this point trying to keep track of all your ideas is impossible, at 
least for me. Have you reconsidered putting it in a repo or at least a Gist yet 
so it is easier to see the scope of your current ideas about packages?

-Mike

Reply via email to