@atlaspack/core 2.12.1-dev.3368 → 2.12.1-dev.3401
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/index.d.ts +8 -0
- package/lib/AtlaspackConfig.js +3 -3
- package/lib/AtlaspackConfig.schema.js +10 -6
- package/lib/BundleGraph.js +3 -3
- package/lib/PackagerRunner.js +1 -1
- package/lib/dumpGraphToGraphViz.js +1 -1
- package/lib/index.js +7 -0
- package/lib/loadAtlaspackPlugin.js +6 -6
- package/lib/public/PluginOptions.js +5 -5
- package/lib/requests/AtlaspackConfigRequest.js +8 -8
- package/lib/resolveOptions.js +3 -3
- package/package.json +16 -16
- package/src/AtlaspackConfig.js +3 -3
- package/src/AtlaspackConfig.schema.js +10 -7
- package/src/BundleGraph.js +3 -3
- package/src/PackagerRunner.js +1 -1
- package/src/dumpGraphToGraphViz.js +1 -1
- package/src/index.js +1 -0
- package/src/loadAtlaspackPlugin.js +14 -14
- package/src/public/PluginOptions.js +5 -5
- package/src/requests/AtlaspackConfigRequest.js +8 -8
- package/src/resolveOptions.js +3 -3
- package/src/types.js +5 -3
- package/test/Atlaspack.test.js +1 -1
- package/test/AtlaspackConfig.test.js +27 -27
- package/test/AtlaspackConfigRequest.test.js +158 -162
- package/test/fixtures/config/{.atlaspackrc → .parcelrc} +1 -1
- package/test/fixtures/config/subfolder/.parcelrc +6 -0
- package/test/fixtures/config-extends-not-found/.parcelrc +3 -0
- package/test/fixtures/config-extends-not-found/.parcelrc-json5 +3 -0
- package/test/fixtures/config-extends-not-found/.parcelrc-multiple +3 -0
- package/test/fixtures/local-plugin-config-pkg/.parcelrc +3 -0
- package/test/fixtures/local-plugin-config-pkg/node_modules/parcel-config-local/package.json +7 -0
- package/test/fixtures/plugins/node_modules/parcel-transformer-bad-engines/package.json +7 -0
- package/test/fixtures/plugins/node_modules/parcel-transformer-no-engines/package.json +4 -0
- package/test/test-utils.js +1 -1
- package/test/fixtures/config/subfolder/.atlaspackrc +0 -6
- package/test/fixtures/config-extends-not-found/.atlaspackrc +0 -3
- package/test/fixtures/config-extends-not-found/.atlaspackrc-json5 +0 -3
- package/test/fixtures/config-extends-not-found/.atlaspackrc-multiple +0 -3
- package/test/fixtures/local-plugin-config-pkg/.atlaspackrc +0 -3
- package/test/fixtures/local-plugin-config-pkg/node_modules/atlaspack-config-local/package.json +0 -7
- package/test/fixtures/plugins/node_modules/atlaspack-transformer-bad-engines/package.json +0 -7
- package/test/fixtures/plugins/node_modules/atlaspack-transformer-no-engines/package.json +0 -4
- /package/test/fixtures/config-extends-not-found/{.atlaspackrc-node-modules → .parcelrc-node-modules} +0 -0
- /package/test/fixtures/config-malformed/{.atlaspackrc → .parcelrc} +0 -0
- /package/test/fixtures/config-node-pipeline/{.atlaspackrc → .parcelrc} +0 -0
- /package/test/fixtures/config-plugin-not-found/{.atlaspackrc → .parcelrc} +0 -0
- /package/test/fixtures/local-plugin-config-pkg/node_modules/{atlaspack-config-local → parcel-config-local}/index.json +0 -0
- /package/test/fixtures/local-plugin-config-pkg/node_modules/{atlaspack-config-local → parcel-config-local}/local-plugin.js +0 -0
- /package/test/fixtures/plugins/node_modules/{atlaspack-transformer-bad-engines → parcel-transformer-bad-engines}/index.js +0 -0
- /package/test/fixtures/plugins/node_modules/{atlaspack-transformer-no-engines → parcel-transformer-no-engines}/index.js +0 -0
package/src/resolveOptions.js
CHANGED
|
@@ -29,10 +29,10 @@ import {DEFAULT_FEATURE_FLAGS} from '@atlaspack/feature-flags';
|
|
|
29
29
|
import {ATLASPACK_VERSION} from './constants';
|
|
30
30
|
|
|
31
31
|
// Default cache directory name
|
|
32
|
-
const DEFAULT_CACHE_DIRNAME = '.
|
|
32
|
+
const DEFAULT_CACHE_DIRNAME = '.parcel-cache';
|
|
33
33
|
const LOCK_FILE_NAMES = ['yarn.lock', 'package-lock.json', 'pnpm-lock.yaml'];
|
|
34
34
|
|
|
35
|
-
// Generate a unique instanceId, will change on every run of
|
|
35
|
+
// Generate a unique instanceId, will change on every run of parcel
|
|
36
36
|
function generateInstanceId(entries: Array<FilePath>): string {
|
|
37
37
|
return hashString(
|
|
38
38
|
`${entries.join(',')}-${Date.now()}-${Math.round(Math.random() * 100)}`,
|
|
@@ -224,7 +224,7 @@ export default async function resolveOptions(
|
|
|
224
224
|
isLibrary: initialOptions?.defaultTargetOptions?.isLibrary,
|
|
225
225
|
},
|
|
226
226
|
featureFlags: {...DEFAULT_FEATURE_FLAGS, ...initialOptions?.featureFlags},
|
|
227
|
-
|
|
227
|
+
parcelVersion: ATLASPACK_VERSION,
|
|
228
228
|
};
|
|
229
229
|
}
|
|
230
230
|
|
package/src/types.js
CHANGED
|
@@ -40,6 +40,7 @@ export type AtlaspackPluginNode = {|
|
|
|
40
40
|
resolveFrom: ProjectPath,
|
|
41
41
|
keyPath?: string,
|
|
42
42
|
|};
|
|
43
|
+
export type ParcelPluginNode = AtlaspackPluginNode;
|
|
43
44
|
|
|
44
45
|
export type PureAtlaspackConfigPipeline = $ReadOnlyArray<AtlaspackPluginNode>;
|
|
45
46
|
export type ExtendableAtlaspackConfigPipeline = $ReadOnlyArray<
|
|
@@ -49,10 +50,10 @@ export type ExtendableAtlaspackConfigPipeline = $ReadOnlyArray<
|
|
|
49
50
|
export type ProcessedAtlaspackConfig = {|
|
|
50
51
|
resolvers?: PureAtlaspackConfigPipeline,
|
|
51
52
|
transformers?: {[Glob]: ExtendableAtlaspackConfigPipeline, ...},
|
|
52
|
-
bundler: ?
|
|
53
|
+
bundler: ?ParcelPluginNode,
|
|
53
54
|
namers?: PureAtlaspackConfigPipeline,
|
|
54
55
|
runtimes?: PureAtlaspackConfigPipeline,
|
|
55
|
-
packagers?: {[Glob]:
|
|
56
|
+
packagers?: {[Glob]: ParcelPluginNode, ...},
|
|
56
57
|
optimizers?: {[Glob]: ExtendableAtlaspackConfigPipeline, ...},
|
|
57
58
|
compressors?: {[Glob]: ExtendableAtlaspackConfigPipeline, ...},
|
|
58
59
|
reporters?: PureAtlaspackConfigPipeline,
|
|
@@ -273,7 +274,7 @@ export type AtlaspackOptions = {|
|
|
|
273
274
|
config?: DependencySpecifier,
|
|
274
275
|
defaultConfig?: DependencySpecifier,
|
|
275
276
|
env: EnvMap,
|
|
276
|
-
|
|
277
|
+
parcelVersion: string,
|
|
277
278
|
targets: ?(Array<string> | {+[string]: TargetDescriptor, ...}),
|
|
278
279
|
shouldDisableCache: boolean,
|
|
279
280
|
cacheDir: FilePath,
|
|
@@ -321,6 +322,7 @@ export type AtlaspackOptions = {|
|
|
|
321
322
|
|
|
322
323
|
+featureFlags: FeatureFlags,
|
|
323
324
|
|};
|
|
325
|
+
export type ParcelOptions = AtlaspackOptions;
|
|
324
326
|
|
|
325
327
|
export type AssetNode = {|
|
|
326
328
|
id: ContentKey,
|
package/test/Atlaspack.test.js
CHANGED
|
@@ -134,7 +134,7 @@ function createAtlaspack(opts?: InitialAtlaspackOptions) {
|
|
|
134
134
|
logLevel: 'info',
|
|
135
135
|
defaultConfig: path.join(
|
|
136
136
|
path.dirname(require.resolve('@atlaspack/test-utils')),
|
|
137
|
-
'.
|
|
137
|
+
'.parcelrc-no-reporters',
|
|
138
138
|
),
|
|
139
139
|
shouldDisableCache: true,
|
|
140
140
|
...opts,
|
|
@@ -10,7 +10,7 @@ import {parseAndProcessConfig} from '../src/requests/AtlaspackConfigRequest';
|
|
|
10
10
|
import {DEFAULT_OPTIONS} from './test-utils';
|
|
11
11
|
import {toProjectPath} from '../src/projectPath';
|
|
12
12
|
|
|
13
|
-
const ATLASPACKRC_PATH = toProjectPath('/', '/.
|
|
13
|
+
const ATLASPACKRC_PATH = toProjectPath('/', '/.parcelrc');
|
|
14
14
|
|
|
15
15
|
describe('AtlaspackConfig', () => {
|
|
16
16
|
describe('matchGlobMap', () => {
|
|
@@ -20,12 +20,12 @@ describe('AtlaspackConfig', () => {
|
|
|
20
20
|
bundler: undefined,
|
|
21
21
|
packagers: {
|
|
22
22
|
'*.css': {
|
|
23
|
-
packageName: '
|
|
23
|
+
packageName: 'parcel-packager-css',
|
|
24
24
|
resolveFrom: ATLASPACKRC_PATH,
|
|
25
25
|
keyPath: '/packagers/*.css',
|
|
26
26
|
},
|
|
27
27
|
'*.js': {
|
|
28
|
-
packageName: '
|
|
28
|
+
packageName: 'parcel-packager-js',
|
|
29
29
|
resolveFrom: ATLASPACKRC_PATH,
|
|
30
30
|
keyPath: '/packagers/*.js',
|
|
31
31
|
},
|
|
@@ -48,7 +48,7 @@ describe('AtlaspackConfig', () => {
|
|
|
48
48
|
config.packagers,
|
|
49
49
|
);
|
|
50
50
|
assert.deepEqual(result, {
|
|
51
|
-
packageName: '
|
|
51
|
+
packageName: 'parcel-packager-js',
|
|
52
52
|
resolveFrom: ATLASPACKRC_PATH,
|
|
53
53
|
keyPath: '/packagers/*.js',
|
|
54
54
|
});
|
|
@@ -63,7 +63,7 @@ describe('AtlaspackConfig', () => {
|
|
|
63
63
|
transformers: {
|
|
64
64
|
'*.jsx': [
|
|
65
65
|
{
|
|
66
|
-
packageName: '
|
|
66
|
+
packageName: 'parcel-transform-jsx',
|
|
67
67
|
resolveFrom: ATLASPACKRC_PATH,
|
|
68
68
|
keyPath: '/transformers/*.jsx/0',
|
|
69
69
|
},
|
|
@@ -71,7 +71,7 @@ describe('AtlaspackConfig', () => {
|
|
|
71
71
|
],
|
|
72
72
|
'*.{js,jsx}': [
|
|
73
73
|
{
|
|
74
|
-
packageName: '
|
|
74
|
+
packageName: 'parcel-transform-js',
|
|
75
75
|
resolveFrom: ATLASPACKRC_PATH,
|
|
76
76
|
keyPath: '/transformers/*.{js,jsx}/0',
|
|
77
77
|
},
|
|
@@ -96,7 +96,7 @@ describe('AtlaspackConfig', () => {
|
|
|
96
96
|
);
|
|
97
97
|
assert.deepEqual(pipeline, [
|
|
98
98
|
{
|
|
99
|
-
packageName: '
|
|
99
|
+
packageName: 'parcel-transform-js',
|
|
100
100
|
resolveFrom: ATLASPACKRC_PATH,
|
|
101
101
|
keyPath: '/transformers/*.{js,jsx}/0',
|
|
102
102
|
},
|
|
@@ -110,12 +110,12 @@ describe('AtlaspackConfig', () => {
|
|
|
110
110
|
);
|
|
111
111
|
assert.deepEqual(pipeline, [
|
|
112
112
|
{
|
|
113
|
-
packageName: '
|
|
113
|
+
packageName: 'parcel-transform-jsx',
|
|
114
114
|
resolveFrom: ATLASPACKRC_PATH,
|
|
115
115
|
keyPath: '/transformers/*.jsx/0',
|
|
116
116
|
},
|
|
117
117
|
{
|
|
118
|
-
packageName: '
|
|
118
|
+
packageName: 'parcel-transform-js',
|
|
119
119
|
resolveFrom: ATLASPACKRC_PATH,
|
|
120
120
|
keyPath: '/transformers/*.{js,jsx}/0',
|
|
121
121
|
},
|
|
@@ -124,11 +124,11 @@ describe('AtlaspackConfig', () => {
|
|
|
124
124
|
});
|
|
125
125
|
|
|
126
126
|
describe('loadPlugin', () => {
|
|
127
|
-
it('should warn if a plugin needs to specify an engines.
|
|
127
|
+
it('should warn if a plugin needs to specify an engines.parcel field in package.json', async () => {
|
|
128
128
|
let projectRoot = path.join(__dirname, 'fixtures', 'plugins');
|
|
129
129
|
let configFilePath = toProjectPath(
|
|
130
130
|
projectRoot,
|
|
131
|
-
path.join(__dirname, 'fixtures', 'plugins', '.
|
|
131
|
+
path.join(__dirname, 'fixtures', 'plugins', '.parcelrc'),
|
|
132
132
|
);
|
|
133
133
|
let config = new AtlaspackConfig(
|
|
134
134
|
{
|
|
@@ -137,7 +137,7 @@ describe('AtlaspackConfig', () => {
|
|
|
137
137
|
transformers: {
|
|
138
138
|
'*.js': [
|
|
139
139
|
{
|
|
140
|
-
packageName: '
|
|
140
|
+
packageName: 'parcel-transformer-no-engines',
|
|
141
141
|
resolveFrom: configFilePath,
|
|
142
142
|
keyPath: '/transformers/*.js/0',
|
|
143
143
|
},
|
|
@@ -149,7 +149,7 @@ describe('AtlaspackConfig', () => {
|
|
|
149
149
|
|
|
150
150
|
let warnStub = sinon.stub(logger, 'warn');
|
|
151
151
|
let {plugin} = await config.loadPlugin({
|
|
152
|
-
packageName: '
|
|
152
|
+
packageName: 'parcel-transformer-no-engines',
|
|
153
153
|
resolveFrom: configFilePath,
|
|
154
154
|
keyPath: '/transformers/*.js/0',
|
|
155
155
|
});
|
|
@@ -159,16 +159,16 @@ describe('AtlaspackConfig', () => {
|
|
|
159
159
|
assert.deepEqual(warnStub.getCall(0).args[0], {
|
|
160
160
|
origin: '@atlaspack/core',
|
|
161
161
|
message:
|
|
162
|
-
'The plugin "
|
|
162
|
+
'The plugin "parcel-transformer-no-engines" needs to specify a `package.json#engines.parcel` field with the supported Atlaspack version range.',
|
|
163
163
|
});
|
|
164
164
|
warnStub.restore();
|
|
165
165
|
});
|
|
166
166
|
|
|
167
|
-
it('should error if a plugin specifies an invalid engines.
|
|
167
|
+
it('should error if a plugin specifies an invalid engines.parcel field in package.json', async () => {
|
|
168
168
|
let projectRoot = path.join(__dirname, 'fixtures', 'plugins');
|
|
169
169
|
let configFilePath = toProjectPath(
|
|
170
170
|
projectRoot,
|
|
171
|
-
path.join(__dirname, 'fixtures', 'plugins', '.
|
|
171
|
+
path.join(__dirname, 'fixtures', 'plugins', '.parcelrc'),
|
|
172
172
|
);
|
|
173
173
|
let config = new AtlaspackConfig(
|
|
174
174
|
{
|
|
@@ -177,7 +177,7 @@ describe('AtlaspackConfig', () => {
|
|
|
177
177
|
transformers: {
|
|
178
178
|
'*.js': [
|
|
179
179
|
{
|
|
180
|
-
packageName: '
|
|
180
|
+
packageName: 'parcel-transformer-not-found',
|
|
181
181
|
resolveFrom: configFilePath,
|
|
182
182
|
keyPath: '/transformers/*.js/0',
|
|
183
183
|
},
|
|
@@ -187,13 +187,13 @@ describe('AtlaspackConfig', () => {
|
|
|
187
187
|
{...DEFAULT_OPTIONS, projectRoot},
|
|
188
188
|
);
|
|
189
189
|
// $FlowFixMe[untyped-import]
|
|
190
|
-
let
|
|
190
|
+
let parcelVersion = require('../package.json').version;
|
|
191
191
|
let pkgJSON = path.join(
|
|
192
192
|
__dirname,
|
|
193
193
|
'fixtures',
|
|
194
194
|
'plugins',
|
|
195
195
|
'node_modules',
|
|
196
|
-
'
|
|
196
|
+
'parcel-transformer-bad-engines',
|
|
197
197
|
'package.json',
|
|
198
198
|
);
|
|
199
199
|
let code = inputFS.readFileSync(pkgJSON, 'utf8');
|
|
@@ -202,7 +202,7 @@ describe('AtlaspackConfig', () => {
|
|
|
202
202
|
await assert.rejects(
|
|
203
203
|
() =>
|
|
204
204
|
config.loadPlugin({
|
|
205
|
-
packageName: '
|
|
205
|
+
packageName: 'parcel-transformer-bad-engines',
|
|
206
206
|
resolveFrom: configFilePath,
|
|
207
207
|
keyPath: '/transformers/*.js/0',
|
|
208
208
|
}),
|
|
@@ -210,7 +210,7 @@ describe('AtlaspackConfig', () => {
|
|
|
210
210
|
name: 'Error',
|
|
211
211
|
diagnostics: [
|
|
212
212
|
{
|
|
213
|
-
message: `The plugin "
|
|
213
|
+
message: `The plugin "parcel-transformer-bad-engines" is not compatible with the current version of Atlaspack. Requires "5.x" but the current version is "${parcelVersion}".`,
|
|
214
214
|
origin: '@atlaspack/core',
|
|
215
215
|
codeFrames: [
|
|
216
216
|
{
|
|
@@ -220,7 +220,7 @@ describe('AtlaspackConfig', () => {
|
|
|
220
220
|
codeHighlights: [
|
|
221
221
|
{
|
|
222
222
|
start: {line: 5, column: 5},
|
|
223
|
-
end: {line: 5, column:
|
|
223
|
+
end: {line: 5, column: 19},
|
|
224
224
|
message: undefined,
|
|
225
225
|
},
|
|
226
226
|
],
|
|
@@ -237,7 +237,7 @@ describe('AtlaspackConfig', () => {
|
|
|
237
237
|
__dirname,
|
|
238
238
|
'fixtures',
|
|
239
239
|
'config-plugin-not-found',
|
|
240
|
-
'.
|
|
240
|
+
'.parcelrc',
|
|
241
241
|
);
|
|
242
242
|
let code = await DEFAULT_OPTIONS.inputFS.readFile(configFilePath, 'utf8');
|
|
243
243
|
let {config} = await parseAndProcessConfig(
|
|
@@ -278,7 +278,7 @@ describe('AtlaspackConfig', () => {
|
|
|
278
278
|
__dirname,
|
|
279
279
|
'fixtures',
|
|
280
280
|
'config-node-pipeline',
|
|
281
|
-
'.
|
|
281
|
+
'.parcelrc',
|
|
282
282
|
);
|
|
283
283
|
let code = await DEFAULT_OPTIONS.inputFS.readFile(configFilePath, 'utf8');
|
|
284
284
|
|
|
@@ -323,7 +323,7 @@ describe('AtlaspackConfig', () => {
|
|
|
323
323
|
let projectRoot = path.join(__dirname, 'fixtures', 'plugins');
|
|
324
324
|
let configFilePath = toProjectPath(
|
|
325
325
|
projectRoot,
|
|
326
|
-
path.join(__dirname, 'fixtures', 'plugins', '.
|
|
326
|
+
path.join(__dirname, 'fixtures', 'plugins', '.parcelrc'),
|
|
327
327
|
);
|
|
328
328
|
let config = new AtlaspackConfig(
|
|
329
329
|
{
|
|
@@ -354,7 +354,7 @@ describe('AtlaspackConfig', () => {
|
|
|
354
354
|
__dirname,
|
|
355
355
|
'fixtures',
|
|
356
356
|
'local-plugin-config-pkg',
|
|
357
|
-
'.
|
|
357
|
+
'.parcelrc',
|
|
358
358
|
);
|
|
359
359
|
let code = await DEFAULT_OPTIONS.inputFS.readFile(configFilePath, 'utf8');
|
|
360
360
|
let {config} = await parseAndProcessConfig(
|
|
@@ -368,7 +368,7 @@ describe('AtlaspackConfig', () => {
|
|
|
368
368
|
'fixtures',
|
|
369
369
|
'local-plugin-config-pkg',
|
|
370
370
|
'node_modules',
|
|
371
|
-
'
|
|
371
|
+
'parcel-config-local',
|
|
372
372
|
'index.json',
|
|
373
373
|
);
|
|
374
374
|
|