@atlaspack/transformer-babel 2.14.21-typescript-bc4459c37.0 → 2.14.21
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 +8 -0
- package/lib/BabelTransformer.js +1 -1
- package/lib/babel7.js +1 -6
- package/lib/config.js +2 -14
- package/lib/flow.js +0 -2
- package/lib/remapAstLocations.js +11 -8
- package/lib/utils.js +0 -3
- package/package.json +10 -15
- package/src/{BabelTransformer.ts → BabelTransformer.js} +6 -4
- package/src/{babel7.ts → babel7.js} +14 -16
- package/src/{babelErrorUtils.ts → babelErrorUtils.js} +8 -5
- package/src/{config.ts → config.js} +22 -49
- package/src/{constants.ts → constants.js} +2 -0
- package/src/{flow.ts → flow.js} +4 -3
- package/src/{jsx.ts → jsx.js} +2 -0
- package/src/{remapAstLocations.ts → remapAstLocations.js} +10 -5
- package/src/types.js +6 -0
- package/src/{utils.ts → utils.js} +4 -4
- package/LICENSE +0 -201
- package/lib/BabelTransformer.d.ts +0 -3
- package/lib/babel7.d.ts +0 -11
- package/lib/babelErrorUtils.d.ts +0 -10
- package/lib/config.d.ts +0 -10
- package/lib/constants.d.ts +0 -1
- package/lib/flow.d.ts +0 -6
- package/lib/jsx.d.ts +0 -6
- package/lib/remapAstLocations.d.ts +0 -3
- package/lib/types.d.ts +0 -4
- package/lib/utils.d.ts +0 -3
- package/src/types.ts +0 -4
- package/tsconfig.json +0 -4
package/CHANGELOG.md
CHANGED
package/lib/BabelTransformer.js
CHANGED
|
@@ -57,6 +57,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
57
57
|
tracer
|
|
58
58
|
}) {
|
|
59
59
|
try {
|
|
60
|
+
// $FlowFixMe
|
|
60
61
|
if (config !== null && config !== void 0 && config.config) {
|
|
61
62
|
if (asset.meta.babelPlugins != null && Array.isArray(asset.meta.babelPlugins)) {
|
|
62
63
|
await (0, _babel.default)({
|
|
@@ -112,7 +113,6 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
112
113
|
if (originalSourceMap) {
|
|
113
114
|
// The babel AST already contains the correct mappings, but not the source contents.
|
|
114
115
|
// We need to copy over the source contents from the original map.
|
|
115
|
-
// @ts-expect-error TS2551
|
|
116
116
|
let sourcesContent = originalSourceMap.getSourcesContentMap();
|
|
117
117
|
for (let filePath in sourcesContent) {
|
|
118
118
|
let content = sourcesContent[filePath];
|
package/lib/babel7.js
CHANGED
|
@@ -37,9 +37,7 @@ var _package = _interopRequireDefault(require("../package.json"));
|
|
|
37
37
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
38
38
|
const transformerVersion = _package.default.version;
|
|
39
39
|
(0, _assert().default)(typeof transformerVersion === 'string');
|
|
40
|
-
async function babel7(opts
|
|
41
|
-
// @ts-expect-error TS2355
|
|
42
|
-
) {
|
|
40
|
+
async function babel7(opts) {
|
|
43
41
|
var _babelOptions$config$;
|
|
44
42
|
let {
|
|
45
43
|
asset,
|
|
@@ -48,7 +46,6 @@ async function babel7(opts
|
|
|
48
46
|
additionalPlugins = [],
|
|
49
47
|
tracer
|
|
50
48
|
} = opts;
|
|
51
|
-
// @ts-expect-error TS2709
|
|
52
49
|
const babelCore = await options.packageManager.require('@babel/core', asset.filePath, {
|
|
53
50
|
range: '^7.12.0',
|
|
54
51
|
saveDev: true,
|
|
@@ -90,7 +87,6 @@ async function babel7(opts
|
|
|
90
87
|
pluginKey = _path().default.relative(options.projectRoot, pluginKey);
|
|
91
88
|
}
|
|
92
89
|
const measurement = tracer.createMeasurement(pluginKey, nodeType, _path().default.relative(options.projectRoot, asset.filePath));
|
|
93
|
-
// @ts-expect-error TS2683
|
|
94
90
|
fn.apply(this, arguments);
|
|
95
91
|
measurement && measurement.end();
|
|
96
92
|
};
|
|
@@ -112,7 +108,6 @@ async function babel7(opts
|
|
|
112
108
|
for (let f of res.externalDependencies) {
|
|
113
109
|
if (!_path().default.isAbsolute(f)) {
|
|
114
110
|
opts.logger.warn({
|
|
115
|
-
// @ts-expect-error TS2345
|
|
116
111
|
message: (0, _diagnostic().md)`Ignoring non-absolute Babel external dependency: ${f}`,
|
|
117
112
|
hints: ['Please report this to the corresponding Babel plugin and/or to Parcel.']
|
|
118
113
|
});
|
package/lib/config.js
CHANGED
|
@@ -59,8 +59,6 @@ async function load(config, options, logger) {
|
|
|
59
59
|
if (!(await (0, _utils().resolveConfig)(options.inputFS, config.searchPath, BABEL_CONFIG_FILENAMES, options.projectRoot))) {
|
|
60
60
|
return buildDefaultBabelConfig(options, config);
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
// @ts-expect-error TS2709
|
|
64
62
|
const babelCore = await options.packageManager.require('@babel/core', config.searchPath, {
|
|
65
63
|
range: _constants.BABEL_CORE_RANGE,
|
|
66
64
|
saveDev: true,
|
|
@@ -222,9 +220,7 @@ function definePluginDependencies(config, babelConfig, options) {
|
|
|
222
220
|
}
|
|
223
221
|
}
|
|
224
222
|
const redundantPresets = new Set(['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript', '@atlaspack/babel-preset-env']);
|
|
225
|
-
async function warnOnRedundantPlugins(
|
|
226
|
-
// @ts-expect-error TS2345
|
|
227
|
-
fs, babelConfig, logger) {
|
|
223
|
+
async function warnOnRedundantPlugins(fs, babelConfig, logger) {
|
|
228
224
|
if (babelConfig == null) {
|
|
229
225
|
return;
|
|
230
226
|
}
|
|
@@ -235,8 +231,6 @@ fs, babelConfig, logger) {
|
|
|
235
231
|
let presets = babelConfig.options.presets || [];
|
|
236
232
|
let plugins = babelConfig.options.plugins || [];
|
|
237
233
|
let foundRedundantPresets = new Set();
|
|
238
|
-
|
|
239
|
-
// @ts-expect-error TS7006
|
|
240
234
|
let filteredPresets = presets.filter(preset => {
|
|
241
235
|
if (redundantPresets.has(preset.file.request)) {
|
|
242
236
|
foundRedundantPresets.add(preset.file.request);
|
|
@@ -248,25 +242,21 @@ fs, babelConfig, logger) {
|
|
|
248
242
|
let diagnostics = [];
|
|
249
243
|
if (filteredPresets.length === 0 && foundRedundantPresets.size > 0 && plugins.length === 0) {
|
|
250
244
|
diagnostics.push({
|
|
251
|
-
// @ts-expect-error TS2345
|
|
252
245
|
message: (0, _diagnostic().md)`Parcel includes transpilation by default. Babel config __${filePath}__ contains only redundant presets. Deleting it may significantly improve build performance.`,
|
|
253
246
|
codeFrames: [{
|
|
254
247
|
filePath: configPath,
|
|
255
248
|
codeHighlights: await getCodeHighlights(fs, configPath, foundRedundantPresets)
|
|
256
249
|
}],
|
|
257
|
-
// @ts-expect-error TS2345
|
|
258
250
|
hints: [(0, _diagnostic().md)`Delete __${filePath}__`],
|
|
259
251
|
documentationURL: 'https://parceljs.org/languages/javascript/#default-presets'
|
|
260
252
|
});
|
|
261
253
|
} else if (foundRedundantPresets.size > 0) {
|
|
262
254
|
diagnostics.push({
|
|
263
|
-
// @ts-expect-error TS2345
|
|
264
255
|
message: (0, _diagnostic().md)`Parcel includes transpilation by default. Babel config __${filePath}__ includes the following redundant presets: ${[...foundRedundantPresets].map(p => _diagnostic().md.underline(p))}. Removing these may improve build performance.`,
|
|
265
256
|
codeFrames: [{
|
|
266
257
|
filePath: configPath,
|
|
267
258
|
codeHighlights: await getCodeHighlights(fs, configPath, foundRedundantPresets)
|
|
268
259
|
}],
|
|
269
|
-
// @ts-expect-error TS2345
|
|
270
260
|
hints: [(0, _diagnostic().md)`Remove the above presets from __${filePath}__`],
|
|
271
261
|
documentationURL: 'https://parceljs.org/languages/javascript/#default-presets'
|
|
272
262
|
});
|
|
@@ -286,9 +276,7 @@ fs, babelConfig, logger) {
|
|
|
286
276
|
logger.warn(diagnostics);
|
|
287
277
|
}
|
|
288
278
|
}
|
|
289
|
-
async function getCodeHighlights(
|
|
290
|
-
// @ts-expect-error TS2339
|
|
291
|
-
fs, filePath, redundantPresets) {
|
|
279
|
+
async function getCodeHighlights(fs, filePath, redundantPresets) {
|
|
292
280
|
let ext = _path().default.extname(filePath);
|
|
293
281
|
if (ext !== '.js' && ext !== '.cjs' && ext !== '.mjs') {
|
|
294
282
|
let contents = await fs.readFile(filePath, 'utf8');
|
package/lib/flow.js
CHANGED
|
@@ -27,8 +27,6 @@ async function getFlowOptions(config, options) {
|
|
|
27
27
|
if (!pkg || !(pkg.dependencies && pkg.dependencies['flow-bin']) && !(pkg.devDependencies && pkg.devDependencies['flow-bin'])) {
|
|
28
28
|
return null;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
// @ts-expect-error TS2709
|
|
32
30
|
const babelCore = await options.packageManager.require('@babel/core', config.searchPath, {
|
|
33
31
|
range: _constants.BABEL_CORE_RANGE,
|
|
34
32
|
saveDev: true,
|
package/lib/remapAstLocations.js
CHANGED
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.remapAstLocations = remapAstLocations;
|
|
7
|
-
function remapAstLocations(
|
|
8
|
-
// @ts-expect-error TS2709
|
|
9
|
-
t, ast, map) {
|
|
7
|
+
function remapAstLocations(t, ast, map) {
|
|
10
8
|
// remap ast to original mappings
|
|
11
9
|
// This improves sourcemap accuracy and fixes sourcemaps when scope-hoisting
|
|
12
10
|
traverseAll(t, ast.program, node => {
|
|
@@ -15,13 +13,20 @@ t, ast, map) {
|
|
|
15
13
|
if ((_node$loc = node.loc) !== null && _node$loc !== void 0 && _node$loc.start) {
|
|
16
14
|
let mapping = map.findClosestMapping(node.loc.start.line, node.loc.start.column);
|
|
17
15
|
if (mapping !== null && mapping !== void 0 && mapping.original) {
|
|
16
|
+
// $FlowFixMe
|
|
18
17
|
node.loc.start.line = mapping.original.line;
|
|
18
|
+
// $FlowFixMe
|
|
19
19
|
node.loc.start.column = mapping.original.column;
|
|
20
|
+
|
|
21
|
+
// $FlowFixMe
|
|
20
22
|
let length = node.loc.end.column - node.loc.start.column;
|
|
23
|
+
|
|
24
|
+
// $FlowFixMe
|
|
21
25
|
node.loc.end.line = mapping.original.line;
|
|
26
|
+
// $FlowFixMe
|
|
22
27
|
node.loc.end.column = mapping.original.column + length;
|
|
23
28
|
|
|
24
|
-
//
|
|
29
|
+
// $FlowFixMe
|
|
25
30
|
node.loc.filename = mapping.source;
|
|
26
31
|
} else {
|
|
27
32
|
// Maintain null mappings?
|
|
@@ -31,15 +36,13 @@ t, ast, map) {
|
|
|
31
36
|
}
|
|
32
37
|
});
|
|
33
38
|
}
|
|
34
|
-
function traverseAll(
|
|
35
|
-
// @ts-expect-error TS2709
|
|
36
|
-
t, node, visitor) {
|
|
39
|
+
function traverseAll(t, node, visitor) {
|
|
37
40
|
if (!node) {
|
|
38
41
|
return;
|
|
39
42
|
}
|
|
40
43
|
visitor(node);
|
|
41
44
|
for (let key of t.VISITOR_KEYS[node.type] || []) {
|
|
42
|
-
//
|
|
45
|
+
// $FlowFixMe
|
|
43
46
|
let subNode = node[key];
|
|
44
47
|
if (Array.isArray(subNode)) {
|
|
45
48
|
for (let i = 0; i < subNode.length; i++) {
|
package/lib/utils.js
CHANGED
|
@@ -19,8 +19,6 @@ function _semver() {
|
|
|
19
19
|
return data;
|
|
20
20
|
}
|
|
21
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
-
// @ts-expect-error TS7016
|
|
23
|
-
|
|
24
22
|
// Copied from @babel/helper-compilation-targets/lib/options.js
|
|
25
23
|
const TargetNames = {
|
|
26
24
|
node: 'node',
|
|
@@ -47,7 +45,6 @@ function enginesToBabelTargets(env) {
|
|
|
47
45
|
// versions, not semver ranges, of its targets.
|
|
48
46
|
let targets = {};
|
|
49
47
|
for (let engineName of Object.keys(env.engines)) {
|
|
50
|
-
// @ts-expect-error TS7053
|
|
51
48
|
let engineValue = env.engines[engineName];
|
|
52
49
|
|
|
53
50
|
// if the engineValue is a string, it might be a semver range. Use the minimum
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/transformer-babel",
|
|
3
|
-
"version": "2.14.21
|
|
3
|
+
"version": "2.14.21",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -9,31 +9,26 @@
|
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/atlassian-labs/atlaspack.git"
|
|
11
11
|
},
|
|
12
|
-
"main": "
|
|
13
|
-
"source": "
|
|
14
|
-
"types": "./lib/BabelTransformer.d.ts",
|
|
12
|
+
"main": "lib/BabelTransformer.js",
|
|
13
|
+
"source": "src/BabelTransformer.js",
|
|
15
14
|
"engines": {
|
|
16
15
|
"node": ">= 16.0.0"
|
|
17
16
|
},
|
|
18
17
|
"dependencies": {
|
|
19
|
-
"@atlaspack/diagnostic": "2.14.
|
|
20
|
-
"@atlaspack/plugin": "2.14.21
|
|
21
|
-
"@atlaspack/utils": "2.17.3-typescript-bc4459c37.0",
|
|
18
|
+
"@atlaspack/diagnostic": "2.14.1",
|
|
19
|
+
"@atlaspack/plugin": "2.14.21",
|
|
22
20
|
"@parcel/source-map": "^2.1.1",
|
|
21
|
+
"@atlaspack/utils": "2.17.3",
|
|
23
22
|
"browserslist": "^4.6.6",
|
|
24
23
|
"json5": "^2.2.0",
|
|
25
24
|
"nullthrows": "^1.1.1",
|
|
26
25
|
"semver": "^7.5.2"
|
|
27
26
|
},
|
|
28
27
|
"devDependencies": {
|
|
29
|
-
"@atlaspack/types": "2.15.11-typescript-bc4459c37.0",
|
|
30
28
|
"@babel/core": "^7.22.11",
|
|
31
29
|
"@babel/preset-env": "^7.22.14",
|
|
32
|
-
"@babel/types": "^7.22.11"
|
|
30
|
+
"@babel/types": "^7.22.11",
|
|
31
|
+
"@atlaspack/types": "2.15.11"
|
|
33
32
|
},
|
|
34
|
-
"type": "commonjs"
|
|
35
|
-
|
|
36
|
-
"check-ts": "tsc --emitDeclarationOnly --rootDir src"
|
|
37
|
-
},
|
|
38
|
-
"gitHead": "bc4459c37a38ef1f74772126637e1d8841d1fcb0"
|
|
39
|
-
}
|
|
33
|
+
"type": "commonjs"
|
|
34
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @flow strict-local
|
|
2
|
+
|
|
1
3
|
import {babelErrorEnhancer} from './babelErrorUtils';
|
|
2
4
|
import {Transformer} from '@atlaspack/plugin';
|
|
3
5
|
import {relativeUrl} from '@atlaspack/utils';
|
|
@@ -6,7 +8,7 @@ import semver from 'semver';
|
|
|
6
8
|
import babel7 from './babel7';
|
|
7
9
|
import {load} from './config';
|
|
8
10
|
|
|
9
|
-
export default new Transformer({
|
|
11
|
+
export default (new Transformer({
|
|
10
12
|
loadConfig({config, options, logger}) {
|
|
11
13
|
return load(config, options, logger);
|
|
12
14
|
},
|
|
@@ -17,6 +19,7 @@ export default new Transformer({
|
|
|
17
19
|
|
|
18
20
|
async transform({asset, config, logger, options, tracer}) {
|
|
19
21
|
try {
|
|
22
|
+
// $FlowFixMe
|
|
20
23
|
if (config?.config) {
|
|
21
24
|
if (
|
|
22
25
|
asset.meta.babelPlugins != null &&
|
|
@@ -42,7 +45,7 @@ export default new Transformer({
|
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
return [asset];
|
|
45
|
-
} catch (e
|
|
48
|
+
} catch (e) {
|
|
46
49
|
throw await babelErrorEnhancer(e, asset);
|
|
47
50
|
}
|
|
48
51
|
},
|
|
@@ -83,7 +86,6 @@ export default new Transformer({
|
|
|
83
86
|
if (originalSourceMap) {
|
|
84
87
|
// The babel AST already contains the correct mappings, but not the source contents.
|
|
85
88
|
// We need to copy over the source contents from the original map.
|
|
86
|
-
// @ts-expect-error TS2551
|
|
87
89
|
let sourcesContent = originalSourceMap.getSourcesContentMap();
|
|
88
90
|
for (let filePath in sourcesContent) {
|
|
89
91
|
let content = sourcesContent[filePath];
|
|
@@ -98,4 +100,4 @@ export default new Transformer({
|
|
|
98
100
|
map,
|
|
99
101
|
};
|
|
100
102
|
},
|
|
101
|
-
})
|
|
103
|
+
}): Transformer<mixed>);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
1
3
|
import type {
|
|
2
4
|
MutableAsset,
|
|
3
5
|
AST,
|
|
@@ -5,7 +7,7 @@ import type {
|
|
|
5
7
|
PluginTracer,
|
|
6
8
|
PluginLogger,
|
|
7
9
|
} from '@atlaspack/types';
|
|
8
|
-
import * as BabelCore from '@babel/core';
|
|
10
|
+
import typeof * as BabelCore from '@babel/core';
|
|
9
11
|
|
|
10
12
|
import invariant from 'assert';
|
|
11
13
|
import path from 'path';
|
|
@@ -15,24 +17,22 @@ import {remapAstLocations} from './remapAstLocations';
|
|
|
15
17
|
|
|
16
18
|
import packageJson from '../package.json';
|
|
17
19
|
|
|
18
|
-
const transformerVersion:
|
|
20
|
+
const transformerVersion: mixed = packageJson.version;
|
|
19
21
|
invariant(typeof transformerVersion === 'string');
|
|
20
22
|
|
|
21
|
-
type Babel7TransformOptions = {
|
|
22
|
-
asset: MutableAsset
|
|
23
|
-
options: PluginOptions
|
|
24
|
-
logger: PluginLogger
|
|
25
|
-
babelOptions: any
|
|
26
|
-
additionalPlugins?: Array<any
|
|
27
|
-
tracer: PluginTracer
|
|
28
|
-
};
|
|
23
|
+
type Babel7TransformOptions = {|
|
|
24
|
+
asset: MutableAsset,
|
|
25
|
+
options: PluginOptions,
|
|
26
|
+
logger: PluginLogger,
|
|
27
|
+
babelOptions: any,
|
|
28
|
+
additionalPlugins?: Array<any>,
|
|
29
|
+
tracer: PluginTracer,
|
|
30
|
+
|};
|
|
29
31
|
|
|
30
32
|
export default async function babel7(
|
|
31
33
|
opts: Babel7TransformOptions,
|
|
32
|
-
|
|
33
|
-
): Promise<AST | null | undefined> {
|
|
34
|
+
): Promise<?AST> {
|
|
34
35
|
let {asset, options, babelOptions, additionalPlugins = [], tracer} = opts;
|
|
35
|
-
// @ts-expect-error TS2709
|
|
36
36
|
const babelCore: BabelCore = await options.packageManager.require(
|
|
37
37
|
'@babel/core',
|
|
38
38
|
asset.filePath,
|
|
@@ -80,7 +80,7 @@ export default async function babel7(
|
|
|
80
80
|
config.wrapPluginVisitorMethod = (
|
|
81
81
|
key: string,
|
|
82
82
|
nodeType: string,
|
|
83
|
-
fn:
|
|
83
|
+
fn: Function,
|
|
84
84
|
) => {
|
|
85
85
|
return function () {
|
|
86
86
|
let pluginKey = key;
|
|
@@ -92,7 +92,6 @@ export default async function babel7(
|
|
|
92
92
|
nodeType,
|
|
93
93
|
path.relative(options.projectRoot, asset.filePath),
|
|
94
94
|
);
|
|
95
|
-
// @ts-expect-error TS2683
|
|
96
95
|
fn.apply(this, arguments);
|
|
97
96
|
measurement && measurement.end();
|
|
98
97
|
};
|
|
@@ -119,7 +118,6 @@ export default async function babel7(
|
|
|
119
118
|
for (let f of res.externalDependencies) {
|
|
120
119
|
if (!path.isAbsolute(f)) {
|
|
121
120
|
opts.logger.warn({
|
|
122
|
-
// @ts-expect-error TS2345
|
|
123
121
|
message: md`Ignoring non-absolute Babel external dependency: ${f}`,
|
|
124
122
|
hints: [
|
|
125
123
|
'Please report this to the corresponding Babel plugin and/or to Parcel.',
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
// @flow
|
|
1
2
|
import type {BaseAsset} from '@atlaspack/types';
|
|
2
3
|
|
|
3
4
|
export type BabelError = Error & {
|
|
4
5
|
loc?: {
|
|
5
|
-
line: number
|
|
6
|
-
column: number
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
line: number,
|
|
7
|
+
column: number,
|
|
8
|
+
...
|
|
9
|
+
},
|
|
10
|
+
source?: string,
|
|
11
|
+
filePath?: string,
|
|
12
|
+
...
|
|
10
13
|
};
|
|
11
14
|
|
|
12
15
|
export async function babelErrorEnhancer(
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
1
3
|
import type {Config, PluginOptions, PluginLogger} from '@atlaspack/types';
|
|
2
|
-
import * as BabelCore from '@babel/core';
|
|
4
|
+
import typeof * as BabelCore from '@babel/core';
|
|
3
5
|
import type {Diagnostic} from '@atlaspack/diagnostic';
|
|
4
6
|
import type {BabelConfig} from './types';
|
|
5
7
|
|
|
@@ -28,18 +30,18 @@ const BABEL_CONFIG_FILENAMES = [
|
|
|
28
30
|
'babel.config.cjs',
|
|
29
31
|
];
|
|
30
32
|
|
|
31
|
-
type BabelConfigResult = {
|
|
32
|
-
internal: boolean
|
|
33
|
-
config: BabelConfig
|
|
34
|
-
targets?:
|
|
35
|
-
syntaxPlugins?:
|
|
36
|
-
};
|
|
33
|
+
type BabelConfigResult = {|
|
|
34
|
+
internal: boolean,
|
|
35
|
+
config: BabelConfig,
|
|
36
|
+
targets?: mixed,
|
|
37
|
+
syntaxPlugins?: mixed,
|
|
38
|
+
|};
|
|
37
39
|
|
|
38
40
|
export async function load(
|
|
39
41
|
config: Config,
|
|
40
42
|
options: PluginOptions,
|
|
41
43
|
logger: PluginLogger,
|
|
42
|
-
): Promise
|
|
44
|
+
): Promise<?BabelConfigResult> {
|
|
43
45
|
// Don't transpile inside node_modules
|
|
44
46
|
if (!config.isSource) {
|
|
45
47
|
return;
|
|
@@ -66,7 +68,6 @@ export async function load(
|
|
|
66
68
|
return buildDefaultBabelConfig(options, config);
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
// @ts-expect-error TS2709
|
|
70
71
|
const babelCore: BabelCore = await options.packageManager.require(
|
|
71
72
|
'@babel/core',
|
|
72
73
|
config.searchPath,
|
|
@@ -97,14 +98,11 @@ export async function load(
|
|
|
97
98
|
showIgnoredFiles: true,
|
|
98
99
|
};
|
|
99
100
|
|
|
100
|
-
let partialConfig:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
| null
|
|
105
|
-
| undefined = await babelCore.loadPartialConfigAsync(babelOptions);
|
|
101
|
+
let partialConfig: ?{|
|
|
102
|
+
[string]: any,
|
|
103
|
+
|} = await babelCore.loadPartialConfigAsync(babelOptions);
|
|
106
104
|
|
|
107
|
-
let addIncludedFile = (file
|
|
105
|
+
let addIncludedFile = (file) => {
|
|
108
106
|
if (JS_EXTNAME_RE.test(path.extname(file))) {
|
|
109
107
|
// We need to invalidate on startup in case the config is non-static,
|
|
110
108
|
// e.g. uses unknown environment variables, reads from the filesystem, etc.
|
|
@@ -175,7 +173,7 @@ export async function load(
|
|
|
175
173
|
return;
|
|
176
174
|
} else if (partialConfig.hasFilesystemConfig()) {
|
|
177
175
|
// Determine what syntax plugins we need to enable
|
|
178
|
-
let syntaxPlugins
|
|
176
|
+
let syntaxPlugins = [];
|
|
179
177
|
if (TYPESCRIPT_EXTNAME_RE.test(config.searchPath)) {
|
|
180
178
|
syntaxPlugins.push('typescript');
|
|
181
179
|
if (config.searchPath.endsWith('.tsx')) {
|
|
@@ -215,7 +213,7 @@ export async function load(
|
|
|
215
213
|
async function buildDefaultBabelConfig(
|
|
216
214
|
options: PluginOptions,
|
|
217
215
|
config: Config,
|
|
218
|
-
): Promise
|
|
216
|
+
): Promise<?BabelConfigResult> {
|
|
219
217
|
// If this is a .ts or .tsx file, we don't need to enable flow.
|
|
220
218
|
if (TYPESCRIPT_EXTNAME_RE.test(config.searchPath)) {
|
|
221
219
|
return;
|
|
@@ -228,7 +226,7 @@ async function buildDefaultBabelConfig(
|
|
|
228
226
|
}
|
|
229
227
|
|
|
230
228
|
// When flow is enabled, we may also need to enable JSX so it parses properly.
|
|
231
|
-
let syntaxPlugins
|
|
229
|
+
let syntaxPlugins = [];
|
|
232
230
|
if (await isJSX(options, config)) {
|
|
233
231
|
syntaxPlugins.push('jsx');
|
|
234
232
|
}
|
|
@@ -241,16 +239,12 @@ async function buildDefaultBabelConfig(
|
|
|
241
239
|
};
|
|
242
240
|
}
|
|
243
241
|
|
|
244
|
-
function hasRequire(options
|
|
242
|
+
function hasRequire(options) {
|
|
245
243
|
let configItems = [...options.presets, ...options.plugins];
|
|
246
244
|
return configItems.some((item) => !item.file);
|
|
247
245
|
}
|
|
248
246
|
|
|
249
|
-
function definePluginDependencies(
|
|
250
|
-
config: Config,
|
|
251
|
-
babelConfig: BabelConfig | null | undefined,
|
|
252
|
-
options: PluginOptions,
|
|
253
|
-
) {
|
|
247
|
+
function definePluginDependencies(config, babelConfig: ?BabelConfig, options) {
|
|
254
248
|
if (babelConfig == null) {
|
|
255
249
|
return;
|
|
256
250
|
}
|
|
@@ -286,14 +280,7 @@ const redundantPresets = new Set([
|
|
|
286
280
|
'@atlaspack/babel-preset-env',
|
|
287
281
|
]);
|
|
288
282
|
|
|
289
|
-
async function warnOnRedundantPlugins(
|
|
290
|
-
// @ts-expect-error TS2345
|
|
291
|
-
fs: FileSystem,
|
|
292
|
-
babelConfig: {
|
|
293
|
-
[key: string]: any;
|
|
294
|
-
},
|
|
295
|
-
logger: PluginLogger,
|
|
296
|
-
) {
|
|
283
|
+
async function warnOnRedundantPlugins(fs, babelConfig, logger) {
|
|
297
284
|
if (babelConfig == null) {
|
|
298
285
|
return;
|
|
299
286
|
}
|
|
@@ -307,7 +294,6 @@ async function warnOnRedundantPlugins(
|
|
|
307
294
|
let plugins = babelConfig.options.plugins || [];
|
|
308
295
|
let foundRedundantPresets = new Set();
|
|
309
296
|
|
|
310
|
-
// @ts-expect-error TS7006
|
|
311
297
|
let filteredPresets = presets.filter((preset) => {
|
|
312
298
|
if (redundantPresets.has(preset.file.request)) {
|
|
313
299
|
foundRedundantPresets.add(preset.file.request);
|
|
@@ -326,7 +312,6 @@ async function warnOnRedundantPlugins(
|
|
|
326
312
|
plugins.length === 0
|
|
327
313
|
) {
|
|
328
314
|
diagnostics.push({
|
|
329
|
-
// @ts-expect-error TS2345
|
|
330
315
|
message: md`Parcel includes transpilation by default. Babel config __${filePath}__ contains only redundant presets. Deleting it may significantly improve build performance.`,
|
|
331
316
|
codeFrames: [
|
|
332
317
|
{
|
|
@@ -338,14 +323,12 @@ async function warnOnRedundantPlugins(
|
|
|
338
323
|
),
|
|
339
324
|
},
|
|
340
325
|
],
|
|
341
|
-
// @ts-expect-error TS2345
|
|
342
326
|
hints: [md`Delete __${filePath}__`],
|
|
343
327
|
documentationURL:
|
|
344
328
|
'https://parceljs.org/languages/javascript/#default-presets',
|
|
345
329
|
});
|
|
346
330
|
} else if (foundRedundantPresets.size > 0) {
|
|
347
331
|
diagnostics.push({
|
|
348
|
-
// @ts-expect-error TS2345
|
|
349
332
|
message: md`Parcel includes transpilation by default. Babel config __${filePath}__ includes the following redundant presets: ${[
|
|
350
333
|
...foundRedundantPresets,
|
|
351
334
|
].map((p) =>
|
|
@@ -361,7 +344,6 @@ async function warnOnRedundantPlugins(
|
|
|
361
344
|
),
|
|
362
345
|
},
|
|
363
346
|
],
|
|
364
|
-
// @ts-expect-error TS2345
|
|
365
347
|
hints: [md`Remove the above presets from __${filePath}__`],
|
|
366
348
|
documentationURL:
|
|
367
349
|
'https://parceljs.org/languages/javascript/#default-presets',
|
|
@@ -395,23 +377,14 @@ async function warnOnRedundantPlugins(
|
|
|
395
377
|
}
|
|
396
378
|
}
|
|
397
379
|
|
|
398
|
-
async function getCodeHighlights(
|
|
399
|
-
// @ts-expect-error TS2339
|
|
400
|
-
fs: FileSystem,
|
|
401
|
-
filePath: any,
|
|
402
|
-
redundantPresets: Set<any | string>,
|
|
403
|
-
) {
|
|
380
|
+
async function getCodeHighlights(fs, filePath, redundantPresets) {
|
|
404
381
|
let ext = path.extname(filePath);
|
|
405
382
|
if (ext !== '.js' && ext !== '.cjs' && ext !== '.mjs') {
|
|
406
383
|
let contents = await fs.readFile(filePath, 'utf8');
|
|
407
384
|
let json = json5.parse(contents);
|
|
408
385
|
|
|
409
386
|
let presets = json.presets || [];
|
|
410
|
-
let pointers
|
|
411
|
-
key: string;
|
|
412
|
-
message?: string;
|
|
413
|
-
type?: 'key' | 'value' | null | undefined;
|
|
414
|
-
}> = [];
|
|
387
|
+
let pointers = [];
|
|
415
388
|
for (let i = 0; i < presets.length; i++) {
|
|
416
389
|
if (Array.isArray(presets[i]) && redundantPresets.has(presets[i][0])) {
|
|
417
390
|
pointers.push({type: 'value', key: `/presets/${i}/0`});
|
package/src/{flow.ts → flow.js}
RENAMED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
1
3
|
import type {Config, PluginOptions, PackageJSON} from '@atlaspack/types';
|
|
2
4
|
import type {BabelConfig} from './types';
|
|
3
|
-
import * as BabelCore from '@babel/core';
|
|
5
|
+
import typeof * as BabelCore from '@babel/core';
|
|
4
6
|
|
|
5
7
|
import {BABEL_CORE_RANGE} from './constants';
|
|
6
8
|
import path from 'path';
|
|
@@ -11,7 +13,7 @@ import path from 'path';
|
|
|
11
13
|
export default async function getFlowOptions(
|
|
12
14
|
config: Config,
|
|
13
15
|
options: PluginOptions,
|
|
14
|
-
): Promise
|
|
16
|
+
): Promise<?BabelConfig> {
|
|
15
17
|
if (!config.isSource) {
|
|
16
18
|
return null;
|
|
17
19
|
}
|
|
@@ -30,7 +32,6 @@ export default async function getFlowOptions(
|
|
|
30
32
|
return null;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
// @ts-expect-error TS2709
|
|
34
35
|
const babelCore: BabelCore = await options.packageManager.require(
|
|
35
36
|
'@babel/core',
|
|
36
37
|
config.searchPath,
|
package/src/{jsx.ts → jsx.js}
RENAMED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
// @flow strict-local
|
|
2
|
+
|
|
1
3
|
import type {File as BabelNodeFile} from '@babel/types';
|
|
2
4
|
import type SourceMap from '@parcel/source-map';
|
|
3
5
|
import type {Node} from '@babel/types';
|
|
4
|
-
import * as BabelTypes from '@babel/types';
|
|
6
|
+
import typeof * as BabelTypes from '@babel/types';
|
|
5
7
|
|
|
6
8
|
export function remapAstLocations(
|
|
7
|
-
// @ts-expect-error TS2709
|
|
8
9
|
t: BabelTypes,
|
|
9
10
|
ast: BabelNodeFile,
|
|
10
11
|
map: SourceMap,
|
|
@@ -20,15 +21,20 @@ export function remapAstLocations(
|
|
|
20
21
|
);
|
|
21
22
|
|
|
22
23
|
if (mapping?.original) {
|
|
24
|
+
// $FlowFixMe
|
|
23
25
|
node.loc.start.line = mapping.original.line;
|
|
26
|
+
// $FlowFixMe
|
|
24
27
|
node.loc.start.column = mapping.original.column;
|
|
25
28
|
|
|
29
|
+
// $FlowFixMe
|
|
26
30
|
let length = node.loc.end.column - node.loc.start.column;
|
|
27
31
|
|
|
32
|
+
// $FlowFixMe
|
|
28
33
|
node.loc.end.line = mapping.original.line;
|
|
34
|
+
// $FlowFixMe
|
|
29
35
|
node.loc.end.column = mapping.original.column + length;
|
|
30
36
|
|
|
31
|
-
//
|
|
37
|
+
// $FlowFixMe
|
|
32
38
|
node.loc.filename = mapping.source;
|
|
33
39
|
} else {
|
|
34
40
|
// Maintain null mappings?
|
|
@@ -40,7 +46,6 @@ export function remapAstLocations(
|
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
function traverseAll(
|
|
43
|
-
// @ts-expect-error TS2709
|
|
44
49
|
t: BabelTypes,
|
|
45
50
|
node: Node,
|
|
46
51
|
visitor: (node: Node) => void,
|
|
@@ -52,7 +57,7 @@ function traverseAll(
|
|
|
52
57
|
visitor(node);
|
|
53
58
|
|
|
54
59
|
for (let key of t.VISITOR_KEYS[node.type] || []) {
|
|
55
|
-
//
|
|
60
|
+
// $FlowFixMe
|
|
56
61
|
let subNode: Node | Array<Node> = node[key];
|
|
57
62
|
if (Array.isArray(subNode)) {
|
|
58
63
|
for (let i = 0; i < subNode.length; i++) {
|
package/src/types.js
ADDED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
1
3
|
import type {Environment} from '@atlaspack/types';
|
|
2
|
-
// @ts-expect-error TS7016
|
|
3
4
|
import type {Targets as BabelTargets} from '@babel/preset-env';
|
|
4
5
|
|
|
5
6
|
import invariant from 'assert';
|
|
@@ -19,7 +20,7 @@ const TargetNames = {
|
|
|
19
20
|
electron: 'electron',
|
|
20
21
|
samsung: 'samsung',
|
|
21
22
|
rhino: 'rhino',
|
|
22
|
-
}
|
|
23
|
+
};
|
|
23
24
|
|
|
24
25
|
// List of browsers to exclude when the esmodule target is specified.
|
|
25
26
|
// Based on https://caniuse.com/#feat=es6-module
|
|
@@ -50,9 +51,8 @@ export function enginesToBabelTargets(env: Environment): BabelTargets {
|
|
|
50
51
|
// This should not be confused with Parcel's own targets.
|
|
51
52
|
// Unlike Parcel's engines, @babel/preset-env expects to work with minimum
|
|
52
53
|
// versions, not semver ranges, of its targets.
|
|
53
|
-
let targets
|
|
54
|
+
let targets = {};
|
|
54
55
|
for (let engineName of Object.keys(env.engines)) {
|
|
55
|
-
// @ts-expect-error TS7053
|
|
56
56
|
let engineValue = env.engines[engineName];
|
|
57
57
|
|
|
58
58
|
// if the engineValue is a string, it might be a semver range. Use the minimum
|
package/LICENSE
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright (c) 2024 Atlassian US., Inc.
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|
package/lib/babel7.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { MutableAsset, AST, PluginOptions, PluginTracer, PluginLogger } from '@atlaspack/types';
|
|
2
|
-
type Babel7TransformOptions = {
|
|
3
|
-
asset: MutableAsset;
|
|
4
|
-
options: PluginOptions;
|
|
5
|
-
logger: PluginLogger;
|
|
6
|
-
babelOptions: any;
|
|
7
|
-
additionalPlugins?: Array<any>;
|
|
8
|
-
tracer: PluginTracer;
|
|
9
|
-
};
|
|
10
|
-
export default function babel7(opts: Babel7TransformOptions): Promise<AST | null | undefined>;
|
|
11
|
-
export {};
|
package/lib/babelErrorUtils.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { BaseAsset } from '@atlaspack/types';
|
|
2
|
-
export type BabelError = Error & {
|
|
3
|
-
loc?: {
|
|
4
|
-
line: number;
|
|
5
|
-
column: number;
|
|
6
|
-
};
|
|
7
|
-
source?: string;
|
|
8
|
-
filePath?: string;
|
|
9
|
-
};
|
|
10
|
-
export declare function babelErrorEnhancer(error: BabelError, asset: BaseAsset): Promise<BabelError>;
|
package/lib/config.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Config, PluginOptions, PluginLogger } from '@atlaspack/types';
|
|
2
|
-
import type { BabelConfig } from './types';
|
|
3
|
-
type BabelConfigResult = {
|
|
4
|
-
internal: boolean;
|
|
5
|
-
config: BabelConfig;
|
|
6
|
-
targets?: unknown;
|
|
7
|
-
syntaxPlugins?: unknown;
|
|
8
|
-
};
|
|
9
|
-
export declare function load(config: Config, options: PluginOptions, logger: PluginLogger): Promise<BabelConfigResult | null | undefined>;
|
|
10
|
-
export {};
|
package/lib/constants.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const BABEL_CORE_RANGE = "^7.12.0";
|
package/lib/flow.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Config, PluginOptions } from '@atlaspack/types';
|
|
2
|
-
import type { BabelConfig } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Generates a babel config for stripping away Flow types.
|
|
5
|
-
*/
|
|
6
|
-
export default function getFlowOptions(config: Config, options: PluginOptions): Promise<BabelConfig | null | undefined>;
|
package/lib/jsx.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Config, PluginOptions } from '@atlaspack/types';
|
|
2
|
-
/**
|
|
3
|
-
* Returns whether an asset is likely JSX. Attempts to detect react or react-like libraries
|
|
4
|
-
* along with
|
|
5
|
-
*/
|
|
6
|
-
export default function isJSX(options: PluginOptions, config: Config): Promise<boolean>;
|
package/lib/types.d.ts
DELETED
package/lib/utils.d.ts
DELETED
package/src/types.ts
DELETED
package/tsconfig.json
DELETED