Recently, I discovered that all the import statements within blocks files were not working on web loading. I changed all the import lines to reference the importmap name. But just now I realized that this change broke all the block files loading within bin/blocks console.
There is a tricky problem in that an import line at the top of a file:
import Service from "../service.js"
Will be interpreted as an importmap line in the browser context but it's expecting a true path in the node context. This PR addresses this inconsistency between the environments.
The solution was to re-do the importmap naming scheme so that all the pretty names are actually the path name. Now even though the import is interpreted differently in the two contexts, it's still is handled properly in both situations.
The only reason this is possible is that the conventions of Blocks are such that any given file is never referred to by two different relative path names. The Service example above, is never imported from a different location such that it's referenced as ../../service.js
Recently, I discovered that all the
import
statements within blocks files were not working on web loading. I changed all the import lines to reference the importmap name. But just now I realized that this change broke all the block files loading withinbin/blocks console
.There is a tricky problem in that an import line at the top of a file:
Will be interpreted as an importmap line in the browser context but it's expecting a true path in the node context. This PR addresses this inconsistency between the environments.
The solution was to re-do the importmap naming scheme so that all the pretty names are actually the path name. Now even though the import is interpreted differently in the two contexts, it's still is handled properly in both situations.
The only reason this is possible is that the conventions of Blocks are such that any given file is never referred to by two different relative path names. The Service example above, is never imported from a different location such that it's referenced as
../../service.js