@atlaspack/transformer-sass 2.14.5-canary.18 → 2.14.5-canary.180

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/CHANGELOG.md CHANGED
@@ -1,5 +1,172 @@
1
1
  # @atlaspack/transformer-sass
2
2
 
3
+ ## 2.14.29
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @atlaspack/plugin@2.14.29
9
+
10
+ ## 2.14.28
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies []:
15
+ - @atlaspack/plugin@2.14.28
16
+
17
+ ## 2.14.27
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies []:
22
+ - @atlaspack/plugin@2.14.27
23
+
24
+ ## 2.14.26
25
+
26
+ ### Patch Changes
27
+
28
+ - [#742](https://github.com/atlassian-labs/atlaspack/pull/742) [`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd) Thanks [@yamadapc](https://github.com/yamadapc)! - Internal changes and bug fixes to environmentDeduplication flag
29
+
30
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd)]:
31
+ - @atlaspack/plugin@2.14.26
32
+
33
+ ## 2.14.25
34
+
35
+ ### Patch Changes
36
+
37
+ - Updated dependencies []:
38
+ - @atlaspack/plugin@2.14.25
39
+
40
+ ## 2.14.24
41
+
42
+ ### Patch Changes
43
+
44
+ - Updated dependencies []:
45
+ - @atlaspack/plugin@2.14.24
46
+
47
+ ## 2.14.23
48
+
49
+ ### Patch Changes
50
+
51
+ - Updated dependencies []:
52
+ - @atlaspack/plugin@2.14.23
53
+
54
+ ## 2.14.22
55
+
56
+ ### Patch Changes
57
+
58
+ - [#720](https://github.com/atlassian-labs/atlaspack/pull/720) [`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94) Thanks [@alshdavid](https://github.com/alshdavid)! - Migrate to TypeScript
59
+
60
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
61
+ - @atlaspack/plugin@2.14.22
62
+
63
+ ## 2.14.21
64
+
65
+ ### Patch Changes
66
+
67
+ - Updated dependencies []:
68
+ - @atlaspack/plugin@2.14.21
69
+
70
+ ## 2.14.20
71
+
72
+ ### Patch Changes
73
+
74
+ - [#702](https://github.com/atlassian-labs/atlaspack/pull/702) [`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa) Thanks [@alshdavid](https://github.com/alshdavid)! - Fixes to Flow types
75
+
76
+ - Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa)]:
77
+ - @atlaspack/plugin@2.14.20
78
+
79
+ ## 2.14.19
80
+
81
+ ### Patch Changes
82
+
83
+ - Updated dependencies []:
84
+ - @atlaspack/plugin@2.14.19
85
+
86
+ ## 2.14.18
87
+
88
+ ### Patch Changes
89
+
90
+ - Updated dependencies []:
91
+ - @atlaspack/plugin@2.14.18
92
+
93
+ ## 2.14.17
94
+
95
+ ### Patch Changes
96
+
97
+ - Updated dependencies []:
98
+ - @atlaspack/plugin@2.14.17
99
+
100
+ ## 2.14.16
101
+
102
+ ### Patch Changes
103
+
104
+ - Updated dependencies []:
105
+ - @atlaspack/plugin@2.14.16
106
+
107
+ ## 2.14.15
108
+
109
+ ### Patch Changes
110
+
111
+ - Updated dependencies []:
112
+ - @atlaspack/plugin@2.14.15
113
+
114
+ ## 2.14.14
115
+
116
+ ### Patch Changes
117
+
118
+ - Updated dependencies []:
119
+ - @atlaspack/plugin@2.14.14
120
+
121
+ ## 2.14.13
122
+
123
+ ### Patch Changes
124
+
125
+ - Updated dependencies []:
126
+ - @atlaspack/plugin@2.14.13
127
+
128
+ ## 2.14.12
129
+
130
+ ### Patch Changes
131
+
132
+ - Updated dependencies []:
133
+ - @atlaspack/plugin@2.14.12
134
+
135
+ ## 2.14.11
136
+
137
+ ### Patch Changes
138
+
139
+ - Updated dependencies []:
140
+ - @atlaspack/plugin@2.14.11
141
+
142
+ ## 2.14.10
143
+
144
+ ### Patch Changes
145
+
146
+ - Updated dependencies []:
147
+ - @atlaspack/plugin@2.14.10
148
+
149
+ ## 2.14.9
150
+
151
+ ### Patch Changes
152
+
153
+ - Updated dependencies []:
154
+ - @atlaspack/plugin@2.14.9
155
+
156
+ ## 2.14.8
157
+
158
+ ### Patch Changes
159
+
160
+ - Updated dependencies []:
161
+ - @atlaspack/plugin@2.14.8
162
+
163
+ ## 2.14.7
164
+
165
+ ### Patch Changes
166
+
167
+ - Updated dependencies []:
168
+ - @atlaspack/plugin@2.14.7
169
+
3
170
  ## 2.14.6
4
171
 
5
172
  ### Patch Changes
@@ -47,6 +47,8 @@ function _util() {
47
47
  return data;
48
48
  }
49
49
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
50
+ // @ts-expect-error TS7016
51
+
50
52
  // E.g: ~library/file.sass
51
53
  const NODE_MODULE_ALIAS_RE = /^~[^/\\]/;
52
54
  var _default = exports.default = new (_plugin().Transformer)({
@@ -67,20 +69,31 @@ var _default = exports.default = new (_plugin().Transformer)({
67
69
  }
68
70
 
69
71
  // Resolve relative paths from config file
72
+ // @ts-expect-error TS18046
70
73
  if (configFile && configResult.includePaths) {
74
+ // @ts-expect-error TS18046
71
75
  configResult.includePaths = configResult.includePaths.map(p => _path().default.resolve(_path().default.dirname(configFile.filePath), p));
72
76
  }
77
+
78
+ // @ts-expect-error TS18046
73
79
  if (configResult.importer === undefined) {
80
+ // @ts-expect-error TS18046
74
81
  configResult.importer = [];
82
+ // @ts-expect-error TS18046
75
83
  } else if (!Array.isArray(configResult.importer)) {
84
+ // @ts-expect-error TS18046
76
85
  configResult.importer = [configResult.importer];
77
86
  }
78
87
 
79
88
  // Always emit sourcemap
89
+ // @ts-expect-error TS18046
80
90
  configResult.sourceMap = true;
81
91
  // sources are created relative to the directory of outFile
92
+ // @ts-expect-error TS18046
82
93
  configResult.outFile = _path().default.join(options.projectRoot, 'style.css.map');
94
+ // @ts-expect-error TS18046
83
95
  configResult.omitSourceMapUrl = true;
96
+ // @ts-expect-error TS18046
84
97
  configResult.sourceMapContents = false;
85
98
  return configResult;
86
99
  },
@@ -98,14 +111,22 @@ var _default = exports.default = new (_plugin().Transformer)({
98
111
  let result = await sassRender({
99
112
  ...rawConfig,
100
113
  file: asset.filePath,
114
+ // @ts-expect-error TS2339
101
115
  data: rawConfig.data ? rawConfig.data + _os().EOL + code : code,
102
- importer: [...rawConfig.importer, resolvePathImporter({
116
+ importer: [
117
+ // @ts-expect-error TS2339
118
+ ...rawConfig.importer, resolvePathImporter({
103
119
  asset,
104
120
  resolve,
121
+ // @ts-expect-error TS2339
105
122
  includePaths: rawConfig.includePaths,
106
123
  options
107
124
  })],
108
- indentedSyntax: typeof rawConfig.indentedSyntax === 'boolean' ? rawConfig.indentedSyntax : asset.type === 'sass'
125
+ indentedSyntax:
126
+ // @ts-expect-error TS2339
127
+ typeof rawConfig.indentedSyntax === 'boolean' ?
128
+ // @ts-expect-error TS2339
129
+ rawConfig.indentedSyntax : asset.type === 'sass'
109
130
  });
110
131
  css = result.css;
111
132
  for (let included of result.stats.includedFiles) {
@@ -131,7 +152,7 @@ var _default = exports.default = new (_plugin().Transformer)({
131
152
  asset.setCode(css);
132
153
  return [asset];
133
154
  }
134
- });
155
+ }); // @ts-expect-error TS7031
135
156
  function resolvePathImporter({
136
157
  asset,
137
158
  resolve,
@@ -158,7 +179,9 @@ function resolvePathImporter({
158
179
  }
159
180
  asset.invalidateOnEnvChange('SASS_PATH');
160
181
  if (options.env.SASS_PATH) {
161
- paths.push(...options.env.SASS_PATH.split(process.platform === 'win32' ? ';' : ':').map(p => _path().default.resolve(options.projectRoot, p)));
182
+ paths.push(...options.env.SASS_PATH.split(process.platform === 'win32' ? ';' : ':'
183
+ // @ts-expect-error TS7006
184
+ ).map(p => _path().default.resolve(options.projectRoot, p)));
162
185
  }
163
186
  const urls = [url];
164
187
  const urlFileName = _path().default.basename(url);
@@ -0,0 +1,3 @@
1
+ import { Transformer } from '@atlaspack/plugin';
2
+ declare const _default: Transformer<unknown>;
3
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/transformer-sass",
3
- "version": "2.14.5-canary.18+556d6ab8e",
3
+ "version": "2.14.5-canary.180+58b9fb037",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -9,16 +9,21 @@
9
9
  "type": "git",
10
10
  "url": "https://github.com/atlassian-labs/atlaspack.git"
11
11
  },
12
- "main": "lib/SassTransformer.js",
13
- "source": "src/SassTransformer.js",
12
+ "main": "./lib/SassTransformer.js",
13
+ "source": "./src/SassTransformer.ts",
14
+ "types": "./lib/types/SassTransformer.d.ts",
14
15
  "engines": {
15
16
  "node": ">= 16.0.0"
16
17
  },
17
18
  "dependencies": {
18
- "@atlaspack/plugin": "2.14.5-canary.18+556d6ab8e",
19
+ "@atlaspack/plugin": "2.14.5-canary.180+58b9fb037",
19
20
  "@parcel/source-map": "^2.1.1",
20
21
  "sass": "^1.38.0"
21
22
  },
22
23
  "type": "commonjs",
23
- "gitHead": "556d6ab8ede759fa7f37fcd3f4da336ef1c55e8f"
24
+ "scripts": {
25
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src",
26
+ "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
27
+ },
28
+ "gitHead": "58b9fb037680a36a0b4af7890f2a03532095b88f"
24
29
  }
@@ -1,15 +1,15 @@
1
- // @flow
2
1
  import {Transformer} from '@atlaspack/plugin';
3
2
  import path from 'path';
4
3
  import {EOL} from 'os';
5
4
  import SourceMap from '@parcel/source-map';
5
+ // @ts-expect-error TS7016
6
6
  import sass from 'sass';
7
7
  import {promisify} from 'util';
8
8
 
9
9
  // E.g: ~library/file.sass
10
10
  const NODE_MODULE_ALIAS_RE = /^~[^/\\]/;
11
11
 
12
- export default (new Transformer({
12
+ export default new Transformer({
13
13
  async loadConfig({config, options}) {
14
14
  let configFile = await config.getConfig(
15
15
  ['.sassrc', '.sassrc.json', '.sassrc.js', '.sassrc.cjs', '.sassrc.mjs'],
@@ -28,23 +28,33 @@ export default (new Transformer({
28
28
  }
29
29
 
30
30
  // Resolve relative paths from config file
31
+ // @ts-expect-error TS18046
31
32
  if (configFile && configResult.includePaths) {
33
+ // @ts-expect-error TS18046
32
34
  configResult.includePaths = configResult.includePaths.map((p) =>
33
35
  path.resolve(path.dirname(configFile.filePath), p),
34
36
  );
35
37
  }
36
38
 
39
+ // @ts-expect-error TS18046
37
40
  if (configResult.importer === undefined) {
41
+ // @ts-expect-error TS18046
38
42
  configResult.importer = [];
43
+ // @ts-expect-error TS18046
39
44
  } else if (!Array.isArray(configResult.importer)) {
45
+ // @ts-expect-error TS18046
40
46
  configResult.importer = [configResult.importer];
41
47
  }
42
48
 
43
49
  // Always emit sourcemap
50
+ // @ts-expect-error TS18046
44
51
  configResult.sourceMap = true;
45
52
  // sources are created relative to the directory of outFile
53
+ // @ts-expect-error TS18046
46
54
  configResult.outFile = path.join(options.projectRoot, 'style.css.map');
55
+ // @ts-expect-error TS18046
47
56
  configResult.omitSourceMapUrl = true;
57
+ // @ts-expect-error TS18046
48
58
  configResult.sourceMapContents = false;
49
59
 
50
60
  return configResult;
@@ -59,19 +69,24 @@ export default (new Transformer({
59
69
  let result = await sassRender({
60
70
  ...rawConfig,
61
71
  file: asset.filePath,
72
+ // @ts-expect-error TS2339
62
73
  data: rawConfig.data ? rawConfig.data + EOL + code : code,
63
74
  importer: [
75
+ // @ts-expect-error TS2339
64
76
  ...rawConfig.importer,
65
77
  resolvePathImporter({
66
78
  asset,
67
79
  resolve,
80
+ // @ts-expect-error TS2339
68
81
  includePaths: rawConfig.includePaths,
69
82
  options,
70
83
  }),
71
84
  ],
72
85
  indentedSyntax:
86
+ // @ts-expect-error TS2339
73
87
  typeof rawConfig.indentedSyntax === 'boolean'
74
- ? rawConfig.indentedSyntax
88
+ ? // @ts-expect-error TS2339
89
+ rawConfig.indentedSyntax
75
90
  : asset.type === 'sass',
76
91
  });
77
92
 
@@ -87,7 +102,7 @@ export default (new Transformer({
87
102
  map.addVLQMap(JSON.parse(result.map));
88
103
  asset.setMap(map);
89
104
  }
90
- } catch (err) {
105
+ } catch (err: any) {
91
106
  // Adapt the Error object for the reporter.
92
107
  err.fileName = err.file;
93
108
  err.loc = {
@@ -102,15 +117,22 @@ export default (new Transformer({
102
117
  asset.setCode(css);
103
118
  return [asset];
104
119
  },
105
- }): Transformer);
120
+ }) as Transformer<unknown>;
106
121
 
122
+ // @ts-expect-error TS7031
107
123
  function resolvePathImporter({asset, resolve, includePaths, options}) {
108
124
  // This is a reimplementation of the Sass resolution algorithm that uses Atlaspack's
109
125
  // FS and tracks all tried files so they are watched for creation.
110
126
  async function resolvePath(
111
- url,
112
- prev,
113
- ): Promise<{filePath: string, contents: string, ...} | void> {
127
+ url: any,
128
+ prev: any,
129
+ ): Promise<
130
+ | {
131
+ filePath: string;
132
+ contents: string;
133
+ }
134
+ | undefined
135
+ > {
114
136
  /*
115
137
  Imports are resolved by trying, in order:
116
138
  * Loading a file relative to the file in which the `@import` appeared.
@@ -133,6 +155,7 @@ function resolvePathImporter({asset, resolve, includePaths, options}) {
133
155
  paths.push(
134
156
  ...options.env.SASS_PATH.split(
135
157
  process.platform === 'win32' ? ';' : ':',
158
+ // @ts-expect-error TS7006
136
159
  ).map((p) => path.resolve(options.projectRoot, p)),
137
160
  );
138
161
  }
@@ -153,7 +176,7 @@ function resolvePathImporter({asset, resolve, includePaths, options}) {
153
176
  filePath,
154
177
  contents,
155
178
  };
156
- } catch (err) {
179
+ } catch (err: any) {
157
180
  asset.invalidateOnFileCreate({filePath});
158
181
  }
159
182
  }
@@ -173,13 +196,13 @@ function resolvePathImporter({asset, resolve, includePaths, options}) {
173
196
  const contents = await asset.fs.readFile(filePath, 'utf8');
174
197
  return {filePath, contents};
175
198
  }
176
- } catch (err) {
199
+ } catch (err: any) {
177
200
  continue;
178
201
  }
179
202
  }
180
203
  }
181
204
 
182
- return function (rawUrl, prev, done) {
205
+ return function (rawUrl: any, prev: any, done: any) {
183
206
  const url = rawUrl.replace(/^file:\/\//, '');
184
207
  resolvePath(url, prev)
185
208
  .then((resolved) => {
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "include": ["src"]
4
+ }