@lls/vitescripts 1.0.0-c94f7be52 → 1.0.0-fff0f08a2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lls/vitescripts",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-fff0f08a2",
|
|
4
4
|
"description": "lls vite plugins",
|
|
5
5
|
"main": "src/index.mjs",
|
|
6
6
|
"files": [
|
|
@@ -16,14 +16,15 @@
|
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@lls/lls-kit": "23.0.0",
|
|
19
|
+
"lodash": "4.17.21",
|
|
19
20
|
"nano-staged": "0.8.0",
|
|
20
21
|
"vitest": "1.0.4"
|
|
21
22
|
},
|
|
22
23
|
"nano-staged": {
|
|
23
|
-
"*.{js,jsx,mjs,tsx,ts}": "
|
|
24
|
+
"*.{js,jsx,mjs,tsx,ts}": "pnpm vitest related --run"
|
|
24
25
|
},
|
|
25
26
|
"scripts": {
|
|
26
|
-
"test": "
|
|
27
|
+
"test": "pnpm vitest run",
|
|
27
28
|
"precommit": "pnpm nano-staged"
|
|
28
29
|
}
|
|
29
30
|
}
|
package/src/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { default as llsAssetsPlugin } from './llsAssetsPlugin.mjs'
|
|
2
2
|
export { default as llsLinariaImportsPlugin } from './llsLinariaImportsPlugin.mjs'
|
|
3
3
|
export { default as llsCssSsrCollectPlugin } from './llsCssSsrCollectPlugin.mjs'
|
|
4
|
-
export { default as llsRequirePlugin } from './llsRequirePlugin.mjs'
|
|
5
4
|
export { default as llsSideRefreshMetaPlugin } from './llsSideRefreshMetaPlugin.mjs'
|
|
6
5
|
export { default as llsVitestMockPlugin } from './llsVitestMockPlugin.mjs'
|
|
7
6
|
export { default as llsLadlePlugin } from './llsLadlePlugin.mjs'
|
package/src/llsAssetsPlugin.mjs
CHANGED
|
@@ -17,6 +17,10 @@ const llsAssetsPlugin = (llsRepos, publicDir = 'ladleassets', { stripRoot = true
|
|
|
17
17
|
const fileExists = (s) => new Promise(resolve => fs.access(s, e => resolve(!e)))
|
|
18
18
|
const srcRoot = process.cwd() + '/src'
|
|
19
19
|
const storyRoot = process.cwd() + '/stories'
|
|
20
|
+
|
|
21
|
+
if (process.env.VITEST) {
|
|
22
|
+
return
|
|
23
|
+
}
|
|
20
24
|
return {
|
|
21
25
|
name: 'lls:copyassets',
|
|
22
26
|
async config () {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import fs from 'fs'
|
|
2
2
|
import path from 'path'
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const toLocal = pkgName => new URL(pkgName, import.meta.url).pathname
|
|
5
|
+
const pwd = toLocal('../')
|
|
5
6
|
|
|
6
7
|
// sideRefreshActiveModules is of the form ['viewer', 'superkit', ...] with 'viewer' if repo launched
|
|
7
8
|
// WITH_VIEWER=1 npm start
|
package/src/llsRequirePlugin.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin using vite-plugin-require-transform, used to transform require syntax to import
|
|
3
|
-
* Needed when we use viewer in sideRefresh
|
|
4
|
-
* @returns the plugin with its transform method
|
|
5
|
-
*/
|
|
6
|
-
const llsSsrRequirePlugin = async () => {
|
|
7
|
-
const VitePluginRequireTransform = await import('vite-plugin-require-transform').then(m => m.default)
|
|
8
|
-
// Lazy loaded viewer modules that are using require syntax
|
|
9
|
-
const fileRegex = /(?:(Audio|Playlist|Recorder|Python|Video|QuestionRich|CodemirrorEditor|useLazyModule)\.jsx$|@lls_lls-code)/
|
|
10
|
-
const back = VitePluginRequireTransform({ fileRegex })
|
|
11
|
-
return {
|
|
12
|
-
name: 'lls:require',
|
|
13
|
-
transform: async function (code, id) {
|
|
14
|
-
const { transform } = await back
|
|
15
|
-
if (fileRegex.test(id)) {
|
|
16
|
-
code = code.replace(/interop\(require\(['"][^'"]+\.browser['"]\)\)/, '() => null')
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
...await transform.apply(this, [code, id]),
|
|
20
|
-
map: null
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default llsSsrRequirePlugin
|