Skip to content

Commit 29f0d30

Browse files
committed
feat: update docker-compose and babelrc configurations for improved development setup
1 parent fda50df commit 29f0d30

3 files changed

Lines changed: 100 additions & 5 deletions

File tree

docker-compose.dev.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services:
55
dockerfile: Dockerfile
66
container_name: sensenet-dev
77
ports:
8-
- "8080:8080"
8+
- "4052:8080"
99
environment:
1010
- NODE_ENV=development
1111
- AUTH_TYPE=SNAuth
@@ -14,6 +14,17 @@ services:
1414
- ALLOWED_HOSTS=all
1515
volumes:
1616
- .:/app
17-
- /app/node_modules
18-
command: yarn snapp start
17+
- sensenet-root-node-modules:/app/node_modules
18+
- sensenet-app-node-modules:/app/apps/sensenet/node_modules
19+
command: sh -c "yarn build && yarn snapp start"
20+
healthcheck:
21+
test: [ "CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:4052/" ]
22+
interval: 30s
23+
timeout: 3s
24+
start_period: 120s
25+
retries: 3
1926
restart: unless-stopped
27+
28+
volumes:
29+
sensenet-root-node-modules:
30+
sensenet-app-node-modules:

packages/sn-document-viewer-react/.babelrc.js

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,47 @@
11
const { BABEL_ENV } = process.env
2+
const { existsSync, lstatSync } = require('fs')
3+
const { dirname, extname, resolve } = require('path')
4+
25
const isBundling = BABEL_ENV === 'bundle'
6+
const scriptExtensions = new Set(['.js', '.ts', '.jsx', '.tsx', '.mjs', '.cjs'])
7+
8+
const addJsExtensionToLocalScriptImports = () => {
9+
const updateSource = (path, state) => {
10+
const { source, exportKind, importKind } = path.node
11+
12+
if (!source || exportKind === 'type' || importKind === 'type') {
13+
return
14+
}
15+
16+
const modulePath = source.value
17+
18+
if (!modulePath.startsWith('.') && !modulePath.startsWith('/')) {
19+
return
20+
}
21+
22+
const extension = extname(modulePath)
23+
24+
if (extension === '.js' || (extension && !scriptExtensions.has(extension))) {
25+
return
26+
}
27+
28+
const absolutePath = resolve(dirname(state.file.opts.filename), modulePath)
29+
const modulePathWithoutExtension = extension ? modulePath.slice(0, -extension.length) : modulePath
30+
31+
source.value =
32+
existsSync(absolutePath) && lstatSync(absolutePath).isDirectory()
33+
? `${modulePath}${modulePathWithoutExtension.endsWith('/') ? '' : '/'}index.js`
34+
: `${modulePathWithoutExtension}.js`
35+
}
36+
37+
return {
38+
visitor: {
39+
ImportDeclaration: updateSource,
40+
ExportNamedDeclaration: updateSource,
41+
ExportAllDeclaration: updateSource,
42+
},
43+
}
44+
}
345

446
const sharedPresets = ['@babel/typescript', '@babel/preset-react']
547

@@ -24,7 +66,7 @@ module.exports = {
2466
],
2567
...sharedPresets,
2668
],
27-
plugins: [...shared.plugins, 'babel-plugin-add-import-extension'],
69+
plugins: [...shared.plugins, addJsExtensionToLocalScriptImports],
2870
},
2971
bundle: {
3072
...shared,

packages/sn-icons-react/.babelrc.js

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,47 @@
11
const { BABEL_ENV } = process.env
2+
const { existsSync, lstatSync } = require('fs')
3+
const { dirname, extname, resolve } = require('path')
4+
25
const isBundling = BABEL_ENV === 'bundle'
6+
const scriptExtensions = new Set(['.js', '.ts', '.jsx', '.tsx', '.mjs', '.cjs'])
7+
8+
const addJsExtensionToLocalScriptImports = () => {
9+
const updateSource = (path, state) => {
10+
const { source, exportKind, importKind } = path.node
11+
12+
if (!source || exportKind === 'type' || importKind === 'type') {
13+
return
14+
}
15+
16+
const modulePath = source.value
17+
18+
if (!modulePath.startsWith('.') && !modulePath.startsWith('/')) {
19+
return
20+
}
21+
22+
const extension = extname(modulePath)
23+
24+
if (extension === '.js' || (extension && !scriptExtensions.has(extension))) {
25+
return
26+
}
27+
28+
const absolutePath = resolve(dirname(state.file.opts.filename), modulePath)
29+
const modulePathWithoutExtension = extension ? modulePath.slice(0, -extension.length) : modulePath
30+
31+
source.value =
32+
existsSync(absolutePath) && lstatSync(absolutePath).isDirectory()
33+
? `${modulePath}${modulePathWithoutExtension.endsWith('/') ? '' : '/'}index.js`
34+
: `${modulePathWithoutExtension}.js`
35+
}
36+
37+
return {
38+
visitor: {
39+
ImportDeclaration: updateSource,
40+
ExportNamedDeclaration: updateSource,
41+
ExportAllDeclaration: updateSource,
42+
},
43+
}
44+
}
345

446
const sharedPresets = ['@babel/typescript', '@babel/preset-react']
547

@@ -24,7 +66,7 @@ module.exports = {
2466
],
2567
...sharedPresets,
2668
],
27-
plugins: [...shared.plugins, 'babel-plugin-add-import-extension'],
69+
plugins: [...shared.plugins, addJsExtensionToLocalScriptImports],
2870
},
2971
bundle: {
3072
...shared,

0 commit comments

Comments
 (0)