@atlaspack/transformer-compiled-external 0.1.1-canary.4112 → 0.1.1-canary.4114

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.
@@ -36,7 +36,17 @@ function findTargetSourcePositions(source, regex) {
36
36
  return results;
37
37
  }
38
38
  exports.default = new plugin_1.Transformer({
39
- async transform({ asset, options }) {
39
+ setup({ options }) {
40
+ return {
41
+ config: {
42
+ projectRoot: options.projectRoot,
43
+ },
44
+ conditions: {
45
+ codeMatch: [/\.compiled\.css$/.source],
46
+ },
47
+ };
48
+ },
49
+ async transform({ asset, config }) {
40
50
  let code = await asset.getCode();
41
51
  if (code.indexOf('.compiled.css') < 0) {
42
52
  // Early exit if no relevant files
@@ -49,7 +59,7 @@ exports.default = new plugin_1.Transformer({
49
59
  continue;
50
60
  if (asset.env.sourceMap) {
51
61
  if (!map)
52
- map = new source_map_1.default(options.projectRoot);
62
+ map = new source_map_1.default(config.projectRoot);
53
63
  map.offsetColumns(match.line + 1, match.column + match.source.length, -match.source.length);
54
64
  }
55
65
  code = code.replace(match.source, '');
@@ -1,3 +1,5 @@
1
1
  import { Transformer } from '@atlaspack/plugin';
2
- declare const _default: Transformer<unknown>;
2
+ declare const _default: Transformer<{
3
+ projectRoot: string;
4
+ }>;
3
5
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/transformer-compiled-external",
3
- "version": "0.1.1-canary.4112+340caf69a",
3
+ "version": "0.1.1-canary.4114+515149d0a",
4
4
  "description": "Atlaspack transformer for handling external Compiled CSS imports (insourced from @compiled/parcel-transformer-external)",
5
5
  "license": "(MIT OR Apache-2.0)",
6
6
  "publishConfig": {
@@ -21,15 +21,15 @@
21
21
  "src"
22
22
  ],
23
23
  "dependencies": {
24
- "@atlaspack/plugin": "2.14.5-canary.333+340caf69a",
25
- "@atlaspack/source-map": "3.2.1-canary.4112+340caf69a"
24
+ "@atlaspack/plugin": "2.14.5-canary.335+515149d0a",
25
+ "@atlaspack/source-map": "3.2.1-canary.4114+515149d0a"
26
26
  },
27
27
  "devDependencies": {
28
- "@atlaspack/types": "2.14.5-canary.333+340caf69a"
28
+ "@atlaspack/types": "2.14.5-canary.335+515149d0a"
29
29
  },
30
30
  "type": "commonjs",
31
31
  "scripts": {
32
32
  "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
33
33
  },
34
- "gitHead": "340caf69a4143bbea119745e2e29a3516d44d522"
34
+ "gitHead": "515149d0a0767d844af803efdc611646780ad0fe"
35
35
  }
@@ -48,7 +48,17 @@ function findTargetSourcePositions(
48
48
  }
49
49
 
50
50
  export default new Transformer({
51
- async transform({asset, options}) {
51
+ setup({options}) {
52
+ return {
53
+ config: {
54
+ projectRoot: options.projectRoot,
55
+ },
56
+ conditions: {
57
+ codeMatch: [/\.compiled\.css$/.source],
58
+ },
59
+ };
60
+ },
61
+ async transform({asset, config}) {
52
62
  let code = await asset.getCode();
53
63
 
54
64
  if (code.indexOf('.compiled.css') < 0) {
@@ -66,7 +76,7 @@ export default new Transformer({
66
76
  if (!specifierPath) continue;
67
77
 
68
78
  if (asset.env.sourceMap) {
69
- if (!map) map = new SourceMap(options.projectRoot);
79
+ if (!map) map = new SourceMap(config.projectRoot);
70
80
 
71
81
  map.offsetColumns(
72
82
  match.line + 1,