@jsenv/core 22.2.0 → 22.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/.DS_Store
ADDED
|
Binary file
|
package/{LICENSE → license}
RENAMED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "22.2.
|
|
3
|
+
"version": "22.2.1",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
"node": ">=14.9.0"
|
|
12
12
|
},
|
|
13
13
|
"publishConfig": {
|
|
14
|
-
"access": "public"
|
|
15
|
-
"registry": "https://registry.npmjs.org"
|
|
14
|
+
"access": "public"
|
|
16
15
|
},
|
|
17
16
|
"type": "module",
|
|
18
17
|
"exports": {
|
package/readme.md
CHANGED
|
@@ -328,17 +328,30 @@ npm install --save-dev @jsenv/core
|
|
|
328
328
|
|
|
329
329
|
# Configuration
|
|
330
330
|
|
|
331
|
-
Jsenv
|
|
332
|
-
The configuration is done via `jsenv.config.mjs` and `babel.config.cjs`.
|
|
331
|
+
Jsenv configuration is done in [jsenv.config.mjs](https://github.com/jsenv/jsenv-core#jsenvconfigmjs) and [babel.config.cjs](https://github.com/jsenv/jsenv-core#babelconfigcjs).
|
|
333
332
|
|
|
334
333
|
## jsenv.config.mjs
|
|
335
334
|
|
|
336
|
-
Jsenv codebase
|
|
335
|
+
Jsenv codebase usually puts configuration in a top level [jsenv.config.mjs](./jsenv.config.mjs) file.
|
|
336
|
+
|
|
337
|
+
```js
|
|
338
|
+
/*
|
|
339
|
+
* This file exports configuration reused by jsenv scripts such as
|
|
340
|
+
*
|
|
341
|
+
* script/test/test.mjs
|
|
342
|
+
* script/build/build.mjs
|
|
343
|
+
*
|
|
344
|
+
* Read more at https://github.com/jsenv/jsenv-core#jsenvconfigmjs
|
|
345
|
+
*/
|
|
346
|
+
|
|
347
|
+
export const projectDirectoryUrl = String(new URL("./", import.meta.url))
|
|
348
|
+
```
|
|
349
|
+
|
|
337
350
|
The file is meant to be imported and passed using the spread operator.
|
|
338
351
|
|
|
339
352
|

|
|
340
353
|
|
|
341
|
-
— See [script/test/test.js](https://github.com/jsenv/jsenv-core/blob/
|
|
354
|
+
— See [script/test/test.js](https://github.com/jsenv/jsenv-core/blob/8da56c4aeb70891be1245f388bfe5d3088145ec6/script/test/test.js#L3)
|
|
342
355
|
|
|
343
356
|
This technic helps to see jsenv custom configuration quickly and share it between files. That being said you are free to organize your configuration as you want.
|
|
344
357
|
|
|
@@ -346,9 +359,16 @@ This technic helps to see jsenv custom configuration quickly and share it betwee
|
|
|
346
359
|
|
|
347
360
|
When code needs to be transformed, the project must contain a [babel config file](https://babeljs.io/docs/en/config-files).
|
|
348
361
|
|
|
349
|
-
It's recommended to use the following
|
|
362
|
+
It's recommended to use the following `babel.config.cjs`
|
|
350
363
|
|
|
351
364
|
```js
|
|
365
|
+
/*
|
|
366
|
+
* This file configure the list of babel plugins enabled
|
|
367
|
+
* in this codebase
|
|
368
|
+
*
|
|
369
|
+
* Read more at https://github.com/jsenv/jsenv-core/tree/master/packages/jsenv-babel-preset
|
|
370
|
+
*/
|
|
371
|
+
|
|
352
372
|
module.exports = {
|
|
353
373
|
presets: ["@jsenv/babel-preset"],
|
|
354
374
|
}
|
|
@@ -372,7 +392,7 @@ export const customCompilers = {
|
|
|
372
392
|
|
|
373
393
|
When your code imports react, it needs to be configured as shown below.
|
|
374
394
|
|
|
375
|
-
_jsenv.config.mjs:_
|
|
395
|
+
_jsenv.config.mjs for react:_
|
|
376
396
|
|
|
377
397
|
```js
|
|
378
398
|
import { commonJsToJavaScriptModule } from "@jsenv/core"
|
|
@@ -95,6 +95,14 @@ export const transformResultToCompilationResult = async (
|
|
|
95
95
|
}
|
|
96
96
|
})
|
|
97
97
|
|
|
98
|
+
if (sources.length === 0) {
|
|
99
|
+
// happens when sourcemap is generated by webpack and looks like
|
|
100
|
+
// webpack://Package./src/file.js
|
|
101
|
+
// in that case we'll don't know how to find the source file
|
|
102
|
+
sources.push(originalFileUrl)
|
|
103
|
+
sourcesContent.push(originalFileContent)
|
|
104
|
+
}
|
|
105
|
+
|
|
98
106
|
await Promise.all(
|
|
99
107
|
sources.map(async (sourceUrl, index) => {
|
|
100
108
|
const contentFromSourcemap = map.sourcesContent
|
|
@@ -168,6 +176,7 @@ const resolveSourceFile = ({
|
|
|
168
176
|
projectDirectoryUrl,
|
|
169
177
|
}) => {
|
|
170
178
|
const sourceFileUrl = resolveSourceUrl({ source, sourcemapFileUrl })
|
|
179
|
+
|
|
171
180
|
if (!sourceFileUrl.startsWith(projectDirectoryUrl)) {
|
|
172
181
|
// do not track dependency outside project
|
|
173
182
|
// it means cache stays valid for those external sources
|