@compiled/parcel-transformer 0.6.17 → 0.7.0
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/dist/transformer.d.ts +1 -1
- package/dist/transformer.js +20 -11
- package/dist/transformer.js.map +1 -1
- package/package.json +10 -9
- package/src/transformer.tsx +20 -11
- package/CHANGELOG.md +0 -86
package/dist/transformer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Transformer } from '@parcel/plugin';
|
|
2
1
|
import type { PluginOptions } from '@compiled/babel-plugin';
|
|
2
|
+
import { Transformer } from '@parcel/plugin';
|
|
3
3
|
declare type UserlandOpts = Omit<PluginOptions, 'cache' | 'onIncludedFiles'>;
|
|
4
4
|
declare const _default: Transformer<UserlandOpts>;
|
|
5
5
|
/**
|
package/dist/transformer.js
CHANGED
|
@@ -3,9 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const plugin_1 = require("@parcel/plugin");
|
|
7
6
|
const core_1 = require("@babel/core");
|
|
8
7
|
const generator_1 = __importDefault(require("@babel/generator"));
|
|
8
|
+
const plugin_1 = require("@parcel/plugin");
|
|
9
|
+
const source_map_1 = __importDefault(require("@parcel/source-map"));
|
|
9
10
|
const configFiles = [
|
|
10
11
|
'.compiledcssrc',
|
|
11
12
|
'.compiledcssrc.json',
|
|
@@ -22,11 +23,10 @@ exports.default = new plugin_1.Transformer({
|
|
|
22
23
|
});
|
|
23
24
|
const contents = {};
|
|
24
25
|
if (conf) {
|
|
25
|
-
config.
|
|
26
|
+
config.invalidateOnStartup();
|
|
26
27
|
Object.assign(contents, conf.contents);
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
config.setResult(contents);
|
|
29
|
+
return contents;
|
|
30
30
|
},
|
|
31
31
|
canReuseAST() {
|
|
32
32
|
// Compiled should run before any other JS transformer.
|
|
@@ -42,12 +42,16 @@ exports.default = new plugin_1.Transformer({
|
|
|
42
42
|
// For everything else we bail out.
|
|
43
43
|
return undefined;
|
|
44
44
|
}
|
|
45
|
-
const
|
|
45
|
+
const program = await (0, core_1.parseAsync)(code, {
|
|
46
46
|
filename: asset.filePath,
|
|
47
47
|
caller: { name: 'compiled' },
|
|
48
48
|
rootMode: 'upward-optional',
|
|
49
49
|
});
|
|
50
|
-
return
|
|
50
|
+
return {
|
|
51
|
+
type: 'babel',
|
|
52
|
+
version: '7.0.0',
|
|
53
|
+
program,
|
|
54
|
+
};
|
|
51
55
|
},
|
|
52
56
|
async transform({ asset, config }) {
|
|
53
57
|
const ast = await asset.getAST();
|
|
@@ -58,7 +62,7 @@ exports.default = new plugin_1.Transformer({
|
|
|
58
62
|
}
|
|
59
63
|
const includedFiles = [];
|
|
60
64
|
const code = asset.isASTDirty() ? undefined : await asset.getCode();
|
|
61
|
-
const result = await core_1.transformFromAstAsync(ast.program, code, {
|
|
65
|
+
const result = await (0, core_1.transformFromAstAsync)(ast.program, code, {
|
|
62
66
|
code: false,
|
|
63
67
|
ast: true,
|
|
64
68
|
filename: asset.filePath,
|
|
@@ -79,7 +83,7 @@ exports.default = new plugin_1.Transformer({
|
|
|
79
83
|
// Included files are those which have been statically evaluated into this asset.
|
|
80
84
|
// This tells parcel that if any of those files change this asset should be transformed
|
|
81
85
|
// again.
|
|
82
|
-
asset.
|
|
86
|
+
asset.invalidateOnFileChange(file);
|
|
83
87
|
});
|
|
84
88
|
if (result === null || result === void 0 ? void 0 : result.ast) {
|
|
85
89
|
asset.setAST({
|
|
@@ -92,14 +96,19 @@ exports.default = new plugin_1.Transformer({
|
|
|
92
96
|
}
|
|
93
97
|
return [asset];
|
|
94
98
|
},
|
|
95
|
-
generate({
|
|
99
|
+
async generate({ asset, ast }) {
|
|
96
100
|
// TODO: We're using babels standard generator. Internally parcel does some hacks in
|
|
97
101
|
// the official Babel transformer to make it faster - using ASTree directly.
|
|
98
102
|
// Perhaps we should do the same thing.
|
|
99
|
-
const { code, map } = generator_1.default(ast.program, {
|
|
103
|
+
const { code, map: babelMap } = (0, generator_1.default)(ast.program, {
|
|
100
104
|
filename: asset.filePath,
|
|
105
|
+
sourceMaps: true,
|
|
106
|
+
sourceFileName: asset.filePath,
|
|
101
107
|
});
|
|
102
|
-
return {
|
|
108
|
+
return {
|
|
109
|
+
content: code,
|
|
110
|
+
map: babelMap ? new source_map_1.default().addVLQMap(babelMap) : null,
|
|
111
|
+
};
|
|
103
112
|
},
|
|
104
113
|
});
|
|
105
114
|
//# sourceMappingURL=transformer.js.map
|
package/dist/transformer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformer.js","sourceRoot":"","sources":["../src/transformer.tsx"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"transformer.js","sourceRoot":"","sources":["../src/transformer.tsx"],"names":[],"mappings":";;;;;AAAA,sCAAgE;AAChE,iEAAwC;AAExC,2CAA6C;AAC7C,oEAA2C;AAI3C,MAAM,WAAW,GAAG;IAClB,gBAAgB;IAChB,qBAAqB;IACrB,gBAAgB;IAChB,uBAAuB;CACxB,CAAC;AAEF;;GAEG;AACH,kBAAe,IAAI,oBAAW,CAAe;IAC3C,KAAK,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE;QACzB,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE;YAC/C,UAAU,EAAE,8BAA8B;SAC3C,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAiB,EAAE,CAAC;QAElC,IAAI,IAAI,EAAE;YACR,MAAM,CAAC,mBAAmB,EAAE,CAAC;YAC7B,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;SACxC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,WAAW;QACT,uDAAuD;Q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AC,IAAI;SAC3D,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@compiled/parcel-transformer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "A familiar and performant compile time CSS-in-JS library for React.",
|
|
5
|
-
"homepage": "https://compiledcssinjs.com",
|
|
5
|
+
"homepage": "https://compiledcssinjs.com/docs/pkg-parcel-transformer",
|
|
6
6
|
"bugs": "https://github.com/atlassian-labs/compiled/issues/new?assignees=&labels=bug&template=bug_report.md",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -21,16 +21,17 @@
|
|
|
21
21
|
"README.md"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@babel/core": "^7.16.
|
|
25
|
-
"@babel/generator": "^7.16.
|
|
26
|
-
"@compiled/babel-plugin": "^0.
|
|
27
|
-
"@compiled/utils": "^0.6.
|
|
28
|
-
"@parcel/plugin": "^2.
|
|
24
|
+
"@babel/core": "^7.16.7",
|
|
25
|
+
"@babel/generator": "^7.16.8",
|
|
26
|
+
"@compiled/babel-plugin": "^0.12.0",
|
|
27
|
+
"@compiled/utils": "^0.6.13",
|
|
28
|
+
"@parcel/plugin": "^2.2.1",
|
|
29
|
+
"@parcel/source-map": "^2.0.1"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
|
-
"@types/babel__core": "^7.1.
|
|
32
|
+
"@types/babel__core": "^7.1.18"
|
|
32
33
|
},
|
|
33
34
|
"engines": {
|
|
34
|
-
"parcel": "^2.0.0
|
|
35
|
+
"parcel": "^2.0.0"
|
|
35
36
|
}
|
|
36
37
|
}
|
package/src/transformer.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Transformer } from '@parcel/plugin';
|
|
2
|
-
import type { PluginOptions } from '@compiled/babel-plugin';
|
|
3
1
|
import { parseAsync, transformFromAstAsync } from '@babel/core';
|
|
4
2
|
import generate from '@babel/generator';
|
|
3
|
+
import type { PluginOptions } from '@compiled/babel-plugin';
|
|
4
|
+
import { Transformer } from '@parcel/plugin';
|
|
5
|
+
import SourceMap from '@parcel/source-map';
|
|
5
6
|
|
|
6
7
|
type UserlandOpts = Omit<PluginOptions, 'cache' | 'onIncludedFiles'>;
|
|
7
8
|
|
|
@@ -24,12 +25,11 @@ export default new Transformer<UserlandOpts>({
|
|
|
24
25
|
const contents: UserlandOpts = {};
|
|
25
26
|
|
|
26
27
|
if (conf) {
|
|
27
|
-
config.
|
|
28
|
+
config.invalidateOnStartup();
|
|
28
29
|
Object.assign(contents, conf.contents);
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
config.setResult(contents);
|
|
32
|
+
return contents;
|
|
33
33
|
},
|
|
34
34
|
|
|
35
35
|
canReuseAST() {
|
|
@@ -49,13 +49,17 @@ export default new Transformer<UserlandOpts>({
|
|
|
49
49
|
return undefined;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
const
|
|
52
|
+
const program = await parseAsync(code, {
|
|
53
53
|
filename: asset.filePath,
|
|
54
54
|
caller: { name: 'compiled' },
|
|
55
55
|
rootMode: 'upward-optional',
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
return
|
|
58
|
+
return {
|
|
59
|
+
type: 'babel',
|
|
60
|
+
version: '7.0.0',
|
|
61
|
+
program,
|
|
62
|
+
};
|
|
59
63
|
},
|
|
60
64
|
|
|
61
65
|
async transform({ asset, config }) {
|
|
@@ -95,7 +99,7 @@ export default new Transformer<UserlandOpts>({
|
|
|
95
99
|
// Included files are those which have been statically evaluated into this asset.
|
|
96
100
|
// This tells parcel that if any of those files change this asset should be transformed
|
|
97
101
|
// again.
|
|
98
|
-
asset.
|
|
102
|
+
asset.invalidateOnFileChange(file);
|
|
99
103
|
});
|
|
100
104
|
|
|
101
105
|
if (result?.ast) {
|
|
@@ -111,14 +115,19 @@ export default new Transformer<UserlandOpts>({
|
|
|
111
115
|
return [asset];
|
|
112
116
|
},
|
|
113
117
|
|
|
114
|
-
generate({
|
|
118
|
+
async generate({ asset, ast }) {
|
|
115
119
|
// TODO: We're using babels standard generator. Internally parcel does some hacks in
|
|
116
120
|
// the official Babel transformer to make it faster - using ASTree directly.
|
|
117
121
|
// Perhaps we should do the same thing.
|
|
118
|
-
const { code, map } = generate(ast.program, {
|
|
122
|
+
const { code, map: babelMap } = generate(ast.program, {
|
|
119
123
|
filename: asset.filePath,
|
|
124
|
+
sourceMaps: true,
|
|
125
|
+
sourceFileName: asset.filePath,
|
|
120
126
|
});
|
|
121
127
|
|
|
122
|
-
return {
|
|
128
|
+
return {
|
|
129
|
+
content: code,
|
|
130
|
+
map: babelMap ? new SourceMap().addVLQMap(babelMap) : null,
|
|
131
|
+
};
|
|
123
132
|
},
|
|
124
133
|
});
|
package/CHANGELOG.md
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
# @compiled/parcel-transformer
|
|
2
|
-
|
|
3
|
-
## 0.6.17
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Updated dependencies [e015a3a]
|
|
8
|
-
- Updated dependencies [fa6af90]
|
|
9
|
-
- @compiled/babel-plugin@0.11.0
|
|
10
|
-
|
|
11
|
-
## 0.6.16
|
|
12
|
-
|
|
13
|
-
### Patch Changes
|
|
14
|
-
|
|
15
|
-
- Updated dependencies [b68411c]
|
|
16
|
-
- Updated dependencies [53a3d71]
|
|
17
|
-
- @compiled/babel-plugin@0.10.0
|
|
18
|
-
|
|
19
|
-
## 0.6.15
|
|
20
|
-
|
|
21
|
-
### Patch Changes
|
|
22
|
-
|
|
23
|
-
- Updated dependencies [0b60ae1]
|
|
24
|
-
- Updated dependencies [2092839]
|
|
25
|
-
- @compiled/babel-plugin@0.9.0
|
|
26
|
-
|
|
27
|
-
## 0.6.14
|
|
28
|
-
|
|
29
|
-
### Patch Changes
|
|
30
|
-
|
|
31
|
-
- Updated dependencies [53935b3]
|
|
32
|
-
- @compiled/babel-plugin@0.8.0
|
|
33
|
-
|
|
34
|
-
## 0.6.13
|
|
35
|
-
|
|
36
|
-
### Patch Changes
|
|
37
|
-
|
|
38
|
-
- Updated dependencies [bcb2a68]
|
|
39
|
-
- Updated dependencies [a7ab8e1]
|
|
40
|
-
- Updated dependencies [e1dc346]
|
|
41
|
-
- Updated dependencies [48805ec]
|
|
42
|
-
- Updated dependencies [587e729]
|
|
43
|
-
- @compiled/babel-plugin@0.7.0
|
|
44
|
-
|
|
45
|
-
## 0.6.12
|
|
46
|
-
|
|
47
|
-
### Patch Changes
|
|
48
|
-
|
|
49
|
-
- 40bc0d9: Package descriptions have been updated.
|
|
50
|
-
- Updated dependencies [40bc0d9]
|
|
51
|
-
- Updated dependencies [1b1c964]
|
|
52
|
-
- @compiled/babel-plugin@0.6.13
|
|
53
|
-
- @compiled/utils@0.6.11
|
|
54
|
-
|
|
55
|
-
## 0.6.11
|
|
56
|
-
|
|
57
|
-
### Patch Changes
|
|
58
|
-
|
|
59
|
-
- 6a7261e: Programmatic babel use now searches upwards for a project root, and if found will use that config. This fixes issues in some monorepo setups.
|
|
60
|
-
|
|
61
|
-
## 0.6.10
|
|
62
|
-
|
|
63
|
-
### Patch Changes
|
|
64
|
-
|
|
65
|
-
- 37108e4: Compiled dependencies are now using carat range.
|
|
66
|
-
- Updated dependencies [992e401]
|
|
67
|
-
- Updated dependencies [37108e4]
|
|
68
|
-
- @compiled/utils@0.6.10
|
|
69
|
-
- @compiled/babel-plugin@0.6.10
|
|
70
|
-
|
|
71
|
-
## 0.6.9
|
|
72
|
-
|
|
73
|
-
### Patch Changes
|
|
74
|
-
|
|
75
|
-
- Updated dependencies [0bb1c11]
|
|
76
|
-
- @compiled/utils@0.6.9
|
|
77
|
-
- @compiled/babel-plugin@0.6.9
|
|
78
|
-
|
|
79
|
-
## 0.6.8
|
|
80
|
-
|
|
81
|
-
### Patch Changes
|
|
82
|
-
|
|
83
|
-
- aea3504: Packages now released with [changesets](https://github.com/atlassian/changesets).
|
|
84
|
-
- Updated dependencies [aea3504]
|
|
85
|
-
- @compiled/babel-plugin@0.6.8
|
|
86
|
-
- @compiled/utils@0.6.8
|