Typesafety for inlang.config.js || allow top level imports from node modules in inlang.config.js
#431
Replies: 2 comments 3 replies
-
Finding a better way to import files is welcome! Step 2 will be the hard one. Detecting all imports in the inlang.config.js file is not enough. Detecting all imports from imported files is necessary too, if we break the rule that imports can only be conducted with
Inlang is supposed to be stack agnostic. Flutter, iOS, Android projects won't have a package.json file and neither would a Deno project.
If we were to implement Using sandboxing to modify import callThe desired effect of using |
Beta Was this translation helpful? Give feedback.
-
Outdated after #1142.
|
Beta Was this translation helpful? Give feedback.
-
Problem
Regular imports like the following do not work currently:
We need to use the
env.$import
utility function and then we can only import a file from an url. Regularnode_modules
imports won't work. This also means that we don't get anyTypeScript
autocompletions.Solution
The
inlang.config.js
could be modified in-memory before it's content get read. Theimport
statements could get transformed and node modules could get resolved, downloaded and the correct entry-point could get found reading theexports
map insidepackage.json
.This should be pretty straightforward and improve DX a lot because there is nothing new to learn.
We should not re-implement the full node resolution algorithm, as all inlang plugins should in theory be "modern", if they use the template repository.
The process could look like this:
inlang.config.js
import
statementsimport
statement from point nr. 2Beta Was this translation helpful? Give feedback.
All reactions