tamagui-loader 1.0.0-alpha.21 → 1.0.0-alpha.25

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,13 +1,12 @@
1
1
  {
2
2
  "name": "tamagui-loader",
3
- "version": "1.0.0-alpha.21",
3
+ "version": "1.0.0-alpha.25",
4
4
  "typings": "types",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
7
7
  "module:jsx": "dist/jsx",
8
8
  "files": [
9
9
  "types",
10
- "src",
11
10
  "dist"
12
11
  ],
13
12
  "scripts": {
@@ -15,16 +14,16 @@
15
14
  "watch": "tamagui-build --watch"
16
15
  },
17
16
  "dependencies": {
18
- "@tamagui/static": "^1.0.0-alpha.21",
17
+ "@tamagui/static": "^1.0.0-alpha.25",
19
18
  "fs-extra": "^9.1.0",
20
19
  "loader-utils": "^2.0.0",
21
20
  "lodash": "^4.17.21"
22
21
  },
23
22
  "devDependencies": {
24
- "@tamagui/build": "^1.0.0-alpha.17"
23
+ "@tamagui/build": "^1.0.0-alpha.22"
25
24
  },
26
25
  "publishConfig": {
27
26
  "access": "public"
28
27
  },
29
- "gitHead": "d3cd631f521c6c755d042ebebf95e532af2c628c"
28
+ "gitHead": "38d6b306363a6dd1e52c40e50b8aa6ba697fe743"
30
29
  }
package/src/index.ts DELETED
@@ -1,4 +0,0 @@
1
- process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || 'web'
2
- process.env.TAMAGUI_COMPILE_PROCESS = '1'
3
-
4
- export default require('./loader').loader
package/src/loader.ts DELETED
@@ -1,105 +0,0 @@
1
- import { extname } from 'path'
2
-
3
- import {
4
- TamaguiOptions,
5
- createExtractor,
6
- extractToClassNames,
7
- patchReactNativeWeb,
8
- } from '@tamagui/static'
9
- import { getOptions } from 'loader-utils'
10
-
11
- Error.stackTraceLimit = Infinity
12
- const extractor = createExtractor()
13
-
14
- const stylesByFile = new Map<string, string>()
15
- const stylePathToFilePath = new Map<string, string>()
16
-
17
- let index = 0
18
- let hasLogged = false
19
- let hasPatched = false
20
-
21
- process.env.TAMAGUI_TARGET = 'web'
22
-
23
- export function loader(this: any, source: string) {
24
- this.cacheable()
25
- const callback = this.async()
26
-
27
- if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {
28
- patchReactNativeWeb()
29
- hasPatched = true
30
- }
31
-
32
- try {
33
- const threaded = this.emitFile === undefined
34
- const options: TamaguiOptions = { ...getOptions(this) }
35
-
36
- if (
37
- options.disableExtraction &&
38
- (options.disableDebugAttr || process.env.NODE_ENV !== 'development')
39
- ) {
40
- if (!hasLogged) {
41
- console.log('🥚 Tamagui disableDebug & disableExtraction set, no parsing running')
42
- hasLogged = true
43
- }
44
- return callback(null, source)
45
- }
46
-
47
- const sourcePath = `${this.resourcePath}`
48
- const startsWithComment = source[0] === '/' && source[1] === '/'
49
- const shouldPrintDebug =
50
- (!!process.env.DEBUG &&
51
- (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true)) ||
52
- // supports esbuild style //! comments
53
- (startsWithComment && (source.startsWith('// debug') || source.startsWith('//! debug')))
54
-
55
- // if outputted css
56
- if (options.cssPath || options.cssData) {
57
- const out = options.cssData
58
- ? Buffer.from(options.cssData, 'base64').toString('utf-8')
59
- : stylesByFile.get(stylePathToFilePath.get(sourcePath) ?? sourcePath)
60
- if (!out) {
61
- console.warn(`no styles... ${stylesByFile.keys} ${sourcePath}`)
62
- }
63
- return callback(null, out)
64
- }
65
-
66
- // check if should ignore
67
- if (
68
- startsWithComment &&
69
- (source.startsWith('// tamagui-ignore') || source.startsWith('//! tamagui-ignore'))
70
- ) {
71
- return callback(null, source)
72
- }
73
-
74
- const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`
75
- const extracted = extractToClassNames({
76
- // @ts-ignore
77
- loader: this,
78
- extractor,
79
- source,
80
- threaded,
81
- sourcePath,
82
- cssPath,
83
- options,
84
- shouldPrintDebug,
85
- })
86
-
87
- if (!extracted) {
88
- return callback(null, source)
89
- }
90
-
91
- if (!threaded) {
92
- if (extracted.stylesPath) {
93
- stylePathToFilePath.set(extracted.stylesPath, sourcePath)
94
- }
95
- if (extracted.styles) {
96
- stylesByFile.set(sourcePath, extracted.styles)
97
- }
98
- }
99
-
100
- callback(null, extracted.js, extracted.map)
101
- } catch (err) {
102
- console.error('ERROR', err)
103
- return callback(null, source)
104
- }
105
- }