@s-ui/bundler 9.38.0 → 9.39.0-typescript.2

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.
@@ -67,12 +67,7 @@ const start = async ({
67
67
  } = {}) => {
68
68
  clearConsole()
69
69
  // Warn and crash if required files are missing
70
- if (
71
- !checkRequiredFiles([
72
- path.join(config.context, 'index.html'),
73
- path.join(config.context, 'app.js')
74
- ])
75
- ) {
70
+ if (!checkRequiredFiles([path.join(config.context, 'index.html')])) {
76
71
  log.error(
77
72
  `✖ Required files are missing, create and index.html and app.js inside your src folder.`
78
73
  )
@@ -49,7 +49,7 @@ module.exports = ({config, packagesToLink, linkAll}) => {
49
49
  * if neccesary
50
50
  */
51
51
  const linkLoader = {
52
- test: /\.(jsx?|scss)$/,
52
+ test: /\.(jsx?|tsx?|scss)$/,
53
53
  enforce: 'pre', // this will ensure is execute before transformations
54
54
  use: {
55
55
  loader: require.resolve('./LinkLoader'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s-ui/bundler",
3
- "version": "9.38.0",
3
+ "version": "9.39.0-typescript.2",
4
4
  "description": "Config-free bundler for ES6 React apps.",
5
5
  "bin": {
6
6
  "sui-bundler": "./bin/sui-bundler.js"
@@ -24,6 +24,8 @@
24
24
  "@babel/core": "7.18.10",
25
25
  "@s-ui/helpers": "1",
26
26
  "@s-ui/sass-loader": "1",
27
+ "@swc/core": "1.3.52",
28
+ "@swc/helpers": "0.5.0",
27
29
  "address": "1.2.0",
28
30
  "autoprefixer": "10.4.8",
29
31
  "babel-loader": "8.2.5",
@@ -46,6 +48,7 @@
46
48
  "stream-http": "3.2.0",
47
49
  "strip-ansi": "6.0.1",
48
50
  "style-loader": "3.3.1",
51
+ "swc-loader": "^0.2.1",
49
52
  "url": "0.11.0",
50
53
  "webpack": "5.74.0",
51
54
  "webpack-dev-server": "4.10.0",
package/shared/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const {config} = require('./config.js')
2
2
 
3
- exports.MAIN_ENTRY_POINT = './app.js'
3
+ exports.MAIN_ENTRY_POINT = './app'
4
4
  exports.config = config
5
5
 
6
6
  exports.cleanList = list => list.filter(Boolean)
@@ -1,32 +1,96 @@
1
+ /* eslint-disable no-console */
2
+ import fs from 'fs-extra'
3
+
1
4
  const path = require('path')
2
5
  const {config} = require('./index.js')
3
6
 
7
+ const tsConfigPath = path.join(process.cwd(), 'tsconfig.json')
8
+ let isTypeScriptEnabled = false
9
+
10
+ try {
11
+ if (fs.existsSync(tsConfigPath)) {
12
+ isTypeScriptEnabled = true
13
+ }
14
+ } catch (err) {
15
+ console.error(err)
16
+ }
17
+
18
+ console.log({isTypeScriptEnabled})
19
+
4
20
  const EXCLUDED_FOLDERS_REGEXP = new RegExp(
5
21
  `node_modules(?!${path.sep}@s-ui(${path.sep}studio)(${path.sep}workbench)?${path.sep}src)`
6
22
  )
7
23
 
8
- module.exports = ({isServer = false, supportLegacyBrowsers = true} = {}) => ({
9
- test: /\.jsx?$/,
10
- exclude: EXCLUDED_FOLDERS_REGEXP,
11
- use: [
12
- {
13
- loader: require.resolve('babel-loader'),
14
- options: {
15
- cacheDirectory: true,
16
- cacheCompression: false,
17
- babelrc: false,
18
- compact: true,
19
- presets: [
20
- [
21
- require.resolve('babel-preset-sui'),
22
- {
23
- isServer,
24
- isModern: !supportLegacyBrowsers,
25
- targets: config.targets
24
+ module.exports = ({isServer = false, supportLegacyBrowsers = true} = {}) =>
25
+ isTypeScriptEnabled
26
+ ? {
27
+ test: /\.(js|ts)x?$/,
28
+ exclude: EXCLUDED_FOLDERS_REGEXP,
29
+ use: [
30
+ {
31
+ loader: require.resolve('swc-loader'),
32
+ options: {
33
+ minify: true,
34
+ jsc: {
35
+ parser: {
36
+ syntax: 'typescript',
37
+ tsx: true,
38
+ dynamicImport: true,
39
+ privateMethod: true,
40
+ functionBind: true,
41
+ exportDefaultFrom: true,
42
+ exportNamespaceFrom: true,
43
+ decorators: true,
44
+ decoratorsBeforeExport: true,
45
+ topLevelAwait: true,
46
+ importMeta: true
47
+ },
48
+ transform: {
49
+ legacyDecorator: true,
50
+ react: {
51
+ useBuiltins: true,
52
+ runtime: 'automatic'
53
+ }
54
+ },
55
+ target: 'es5',
56
+ loose: true,
57
+ externalHelpers: true
58
+ },
59
+ env: {
60
+ targets: {
61
+ ie: '11'
62
+ },
63
+ dynamicImport: true,
64
+ loose: true,
65
+ mode: 'entry',
66
+ coreJs: 3
67
+ }
68
+ }
69
+ }
70
+ ]
71
+ }
72
+ : {
73
+ test: /\.jsx?$/,
74
+ exclude: EXCLUDED_FOLDERS_REGEXP,
75
+ use: [
76
+ {
77
+ loader: require.resolve('babel-loader'),
78
+ options: {
79
+ cacheDirectory: true,
80
+ cacheCompression: false,
81
+ babelrc: false,
82
+ compact: true,
83
+ presets: [
84
+ [
85
+ require.resolve('babel-preset-sui'),
86
+ {
87
+ isServer,
88
+ isModern: !supportLegacyBrowsers,
89
+ targets: config.targets
90
+ }
91
+ ]
92
+ ]
26
93
  }
27
- ]
94
+ }
28
95
  ]
29
96
  }
30
- }
31
- ]
32
- })
@@ -47,7 +47,7 @@ const webpackConfig = {
47
47
  timers: false
48
48
  },
49
49
  modules: ['node_modules', path.resolve(process.cwd())],
50
- extensions: ['.js', '.json']
50
+ extensions: ['.js', '.tsx', '.ts', '.json']
51
51
  },
52
52
  stats: 'errors-only',
53
53
  entry: cleanList([