@atlaspack/core 2.16.2-canary.184 → 2.16.2-canary.186

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.
@@ -34,7 +34,8 @@ function createEnvironment({
34
34
  shouldScopeHoist = false,
35
35
  sourceMap,
36
36
  unstableSingleFileOutput = false,
37
- loc
37
+ loc,
38
+ customEnv
38
39
  } = {
39
40
  /*::...null*/
40
41
  }) {
@@ -111,7 +112,8 @@ function createEnvironment({
111
112
  shouldScopeHoist,
112
113
  sourceMap,
113
114
  unstableSingleFileOutput,
114
- loc
115
+ loc,
116
+ customEnv
115
117
  };
116
118
  res.id = getEnvironmentHash(res);
117
119
  return (0, _EnvironmentManager.toEnvironmentRef)(Object.freeze(res));
@@ -140,7 +142,8 @@ function getEnvironmentHash(env) {
140
142
  isLibrary: env.isLibrary,
141
143
  shouldOptimize: env.shouldOptimize,
142
144
  shouldScopeHoist: env.shouldScopeHoist,
143
- sourceMap: env.sourceMap
145
+ sourceMap: env.sourceMap,
146
+ customEnv: env.customEnv
144
147
  };
145
148
  const id = (0, _rust().createEnvironmentId)(data);
146
149
  _IdentifierRegistry.identifierRegistry.addIdentifier('environment', id, data);
@@ -98,6 +98,12 @@ const PACKAGE_DESCRIPTOR_SCHEMA = exports.PACKAGE_DESCRIPTOR_SCHEMA = {
98
98
  },
99
99
  __unstable_singleFileOutput: {
100
100
  type: 'boolean'
101
+ },
102
+ env: {
103
+ type: 'object',
104
+ additionalProperties: {
105
+ type: 'string'
106
+ }
101
107
  }
102
108
  },
103
109
  additionalProperties: false
@@ -21,6 +21,7 @@ class Environment {
21
21
  this.sourceMap = inner.sourceMap;
22
22
  this.loc = inner.loc;
23
23
  this.unstableSingleFileOutput = false;
24
+ this.customEnv = inner.customEnv;
24
25
  }
25
26
  isBrowser() {
26
27
  return this.context === 'browser' || this.isWorker() || this.isTesseract() || this.isWorklet() || this.context === 'electron-renderer';
@@ -178,6 +178,9 @@ class Environment {
178
178
  get unstableSingleFileOutput() {
179
179
  return this.#environment.unstableSingleFileOutput;
180
180
  }
181
+ get customEnv() {
182
+ return this.#environment.customEnv;
183
+ }
181
184
  [inspect]() {
182
185
  return `Env(${this.#environment.context})`;
183
186
  }
@@ -256,7 +256,8 @@ class TargetResolver {
256
256
  shouldOptimize: this.options.defaultTargetOptions.shouldOptimize && descriptor.optimize !== false,
257
257
  shouldScopeHoist: this.options.defaultTargetOptions.shouldScopeHoist && descriptor.scopeHoist !== false,
258
258
  sourceMap: normalizeSourceMap(this.options, descriptor.sourceMap),
259
- unstableSingleFileOutput: descriptor.__unstable_singleFileOutput
259
+ unstableSingleFileOutput: descriptor.__unstable_singleFileOutput,
260
+ customEnv: descriptor.env
260
261
  })
261
262
  };
262
263
  if (descriptor.distEntry != null) {
@@ -1,10 +1,11 @@
1
- import type { EnvironmentOptions, Environment as IEnvironment, FilePath } from '@atlaspack/types';
1
+ import type { EnvironmentOptions, Environment as IEnvironment, FilePath, EnvMap } from '@atlaspack/types';
2
2
  import type { Environment, InternalSourceLocation } from './types';
3
3
  import type { EnvironmentRef } from './EnvironmentManager';
4
4
  type EnvironmentOpts = EnvironmentOptions & {
5
5
  loc?: InternalSourceLocation | null | undefined;
6
+ customEnv?: EnvMap | null | undefined;
6
7
  };
7
- export declare function createEnvironment({ context, engines, includeNodeModules, outputFormat, sourceType, shouldOptimize, isLibrary, shouldScopeHoist, sourceMap, unstableSingleFileOutput, loc, }?: EnvironmentOpts): EnvironmentRef;
8
+ export declare function createEnvironment({ context, engines, includeNodeModules, outputFormat, sourceType, shouldOptimize, isLibrary, shouldScopeHoist, sourceMap, unstableSingleFileOutput, loc, customEnv, }?: EnvironmentOpts): EnvironmentRef;
8
9
  export declare function mergeEnvironments(projectRoot: FilePath, a: Environment, b?: EnvironmentOptions | IEnvironment | null): EnvironmentRef;
9
10
  export declare function getEnvironmentHash(env: Environment): string;
10
11
  export {};
@@ -1,5 +1,5 @@
1
1
  import type { Environment as NapiEnvironment } from '@atlaspack/rust';
2
- import type { Environment as IEnvironment, EnvironmentContext, Engines, PackageName, OutputFormat, SourceType, TargetSourceMapOptions, SourceLocation, VersionMap, EnvironmentFeature } from '@atlaspack/types';
2
+ import type { Environment as IEnvironment, EnvironmentContext, Engines, PackageName, OutputFormat, SourceType, TargetSourceMapOptions, SourceLocation, VersionMap, EnvironmentFeature, EnvMap } from '@atlaspack/types';
3
3
  export declare class Environment implements IEnvironment {
4
4
  id: string;
5
5
  includeNodeModules: boolean | Array<PackageName> | Partial<Record<PackageName, boolean>>;
@@ -13,6 +13,7 @@ export declare class Environment implements IEnvironment {
13
13
  sourceMap: TargetSourceMapOptions | null | undefined;
14
14
  loc: SourceLocation | null | undefined;
15
15
  unstableSingleFileOutput: boolean;
16
+ customEnv: EnvMap | null | undefined;
16
17
  constructor(inner: NapiEnvironment);
17
18
  isBrowser(): boolean;
18
19
  isNode(): boolean;
@@ -1,4 +1,4 @@
1
- import type { Environment as IEnvironment, EnvironmentContext, EnvironmentFeature, Engines, OutputFormat, PackageName, VersionMap, SourceLocation, SourceType, TargetSourceMapOptions } from '@atlaspack/types';
1
+ import type { Environment as IEnvironment, EnvironmentContext, EnvironmentFeature, Engines, OutputFormat, PackageName, VersionMap, SourceLocation, SourceType, TargetSourceMapOptions, EnvMap } from '@atlaspack/types';
2
2
  import type { Environment as InternalEnvironment, AtlaspackOptions } from '../types';
3
3
  declare const inspect: unique symbol;
4
4
  export declare const BROWSER_ENVS: Set<string>;
@@ -19,6 +19,7 @@ export default class Environment implements IEnvironment {
19
19
  get sourceMap(): TargetSourceMapOptions | null | undefined;
20
20
  get loc(): SourceLocation | null | undefined;
21
21
  get unstableSingleFileOutput(): boolean;
22
+ get customEnv(): EnvMap | null | undefined;
22
23
  [inspect](): string;
23
24
  isBrowser(): boolean;
24
25
  isNode(): boolean;
@@ -46,6 +46,7 @@ export type Environment = {
46
46
  sourceMap: TargetSourceMapOptions | null | undefined;
47
47
  loc: InternalSourceLocation | null | undefined;
48
48
  unstableSingleFileOutput: boolean;
49
+ customEnv: EnvMap | null | undefined;
49
50
  };
50
51
  export type InternalSourceLocation = {
51
52
  readonly filePath: ProjectPath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.16.2-canary.184+038e87a78",
3
+ "version": "2.16.2-canary.186+f6532d7a4",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -23,21 +23,21 @@
23
23
  "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
24
24
  },
25
25
  "dependencies": {
26
- "@atlaspack/build-cache": "2.13.3-canary.252+038e87a78",
27
- "@atlaspack/cache": "3.1.1-canary.184+038e87a78",
28
- "@atlaspack/diagnostic": "2.14.1-canary.252+038e87a78",
29
- "@atlaspack/events": "2.14.1-canary.252+038e87a78",
30
- "@atlaspack/feature-flags": "2.14.1-canary.252+038e87a78",
31
- "@atlaspack/fs": "2.14.5-canary.184+038e87a78",
32
- "@atlaspack/graph": "3.4.1-canary.252+038e87a78",
33
- "@atlaspack/logger": "2.14.5-canary.184+038e87a78",
34
- "@atlaspack/package-manager": "2.14.5-canary.184+038e87a78",
35
- "@atlaspack/plugin": "2.14.5-canary.184+038e87a78",
36
- "@atlaspack/profiler": "2.14.1-canary.252+038e87a78",
37
- "@atlaspack/rust": "3.2.1-canary.184+038e87a78",
38
- "@atlaspack/types": "2.14.5-canary.184+038e87a78",
39
- "@atlaspack/utils": "2.14.5-canary.184+038e87a78",
40
- "@atlaspack/workers": "2.14.5-canary.184+038e87a78",
26
+ "@atlaspack/build-cache": "2.13.3-canary.254+f6532d7a4",
27
+ "@atlaspack/cache": "3.1.1-canary.186+f6532d7a4",
28
+ "@atlaspack/diagnostic": "2.14.1-canary.254+f6532d7a4",
29
+ "@atlaspack/events": "2.14.1-canary.254+f6532d7a4",
30
+ "@atlaspack/feature-flags": "2.14.1-canary.254+f6532d7a4",
31
+ "@atlaspack/fs": "2.14.5-canary.186+f6532d7a4",
32
+ "@atlaspack/graph": "3.4.1-canary.254+f6532d7a4",
33
+ "@atlaspack/logger": "2.14.5-canary.186+f6532d7a4",
34
+ "@atlaspack/package-manager": "2.14.5-canary.186+f6532d7a4",
35
+ "@atlaspack/plugin": "2.14.5-canary.186+f6532d7a4",
36
+ "@atlaspack/profiler": "2.14.1-canary.254+f6532d7a4",
37
+ "@atlaspack/rust": "3.2.1-canary.186+f6532d7a4",
38
+ "@atlaspack/types": "2.14.5-canary.186+f6532d7a4",
39
+ "@atlaspack/utils": "2.14.5-canary.186+f6532d7a4",
40
+ "@atlaspack/workers": "2.14.5-canary.186+f6532d7a4",
41
41
  "@mischnic/json-sourcemap": "^0.1.0",
42
42
  "@parcel/source-map": "^2.1.1",
43
43
  "base-x": "^3.0.8",
@@ -62,5 +62,5 @@
62
62
  "./src/serializerCore.js": "./src/serializerCore.browser.js"
63
63
  },
64
64
  "type": "commonjs",
65
- "gitHead": "038e87a7858d39556d59d3a2d17db534d45f62c6"
65
+ "gitHead": "f6532d7a4f7f007bd4e5e36af04dd466f0b9f572"
66
66
  }
@@ -2,6 +2,7 @@ import type {
2
2
  EnvironmentOptions,
3
3
  Environment as IEnvironment,
4
4
  FilePath,
5
+ EnvMap,
5
6
  } from '@atlaspack/types';
6
7
  import type {Environment, InternalSourceLocation} from './types';
7
8
  import {createEnvironmentId} from '@atlaspack/rust';
@@ -19,6 +20,7 @@ const DEFAULT_ENGINES = {
19
20
 
20
21
  type EnvironmentOpts = EnvironmentOptions & {
21
22
  loc?: InternalSourceLocation | null | undefined;
23
+ customEnv?: EnvMap | null | undefined;
22
24
  };
23
25
 
24
26
  export function createEnvironment({
@@ -33,6 +35,7 @@ export function createEnvironment({
33
35
  sourceMap,
34
36
  unstableSingleFileOutput = false,
35
37
  loc,
38
+ customEnv,
36
39
  }: EnvironmentOpts = {
37
40
  /*::...null*/
38
41
  }): EnvironmentRef {
@@ -113,6 +116,7 @@ export function createEnvironment({
113
116
  sourceMap,
114
117
  unstableSingleFileOutput,
115
118
  loc,
119
+ customEnv,
116
120
  };
117
121
 
118
122
  res.id = getEnvironmentHash(res);
@@ -152,6 +156,7 @@ export function getEnvironmentHash(env: Environment): string {
152
156
  shouldOptimize: env.shouldOptimize,
153
157
  shouldScopeHoist: env.shouldScopeHoist,
154
158
  sourceMap: env.sourceMap,
159
+ customEnv: env.customEnv,
155
160
  } as const;
156
161
  const id = createEnvironmentId(data);
157
162
  identifierRegistry.addIdentifier('environment', id, data);
@@ -115,6 +115,12 @@ export const PACKAGE_DESCRIPTOR_SCHEMA: SchemaObject = {
115
115
  __unstable_singleFileOutput: {
116
116
  type: 'boolean',
117
117
  },
118
+ env: {
119
+ type: 'object',
120
+ additionalProperties: {
121
+ type: 'string',
122
+ },
123
+ },
118
124
  },
119
125
  additionalProperties: false,
120
126
  };
@@ -46,6 +46,7 @@ import UncommittedAsset from './UncommittedAsset';
46
46
  import {createAsset} from './assetUtils';
47
47
  import summarizeRequest from './summarizeRequest';
48
48
  import PluginOptions from './public/PluginOptions';
49
+ import {fromEnvironmentId} from './EnvironmentManager';
49
50
  import {optionsProxy} from './utils';
50
51
  import {createConfig} from './InternalConfig';
51
52
  import {
@@ -11,6 +11,7 @@ import type {
11
11
  SourceLocation,
12
12
  VersionMap,
13
13
  EnvironmentFeature,
14
+ EnvMap,
14
15
  } from '@atlaspack/types';
15
16
 
16
17
  export class Environment implements IEnvironment {
@@ -29,6 +30,7 @@ export class Environment implements IEnvironment {
29
30
  sourceMap: TargetSourceMapOptions | null | undefined;
30
31
  loc: SourceLocation | null | undefined;
31
32
  unstableSingleFileOutput: boolean;
33
+ customEnv: EnvMap | null | undefined;
32
34
 
33
35
  constructor(inner: NapiEnvironment) {
34
36
  // TODO
@@ -44,6 +46,7 @@ export class Environment implements IEnvironment {
44
46
  this.sourceMap = inner.sourceMap;
45
47
  this.loc = inner.loc;
46
48
  this.unstableSingleFileOutput = false;
49
+ this.customEnv = inner.customEnv;
47
50
  }
48
51
 
49
52
  isBrowser(): boolean {
@@ -9,6 +9,7 @@ import type {
9
9
  SourceLocation,
10
10
  SourceType,
11
11
  TargetSourceMapOptions,
12
+ EnvMap,
12
13
  } from '@atlaspack/types';
13
14
  import type {
14
15
  Environment as InternalEnvironment,
@@ -232,6 +233,10 @@ export default class Environment implements IEnvironment {
232
233
  return this.#environment.unstableSingleFileOutput;
233
234
  }
234
235
 
236
+ get customEnv(): EnvMap | null | undefined {
237
+ return this.#environment.customEnv;
238
+ }
239
+
235
240
  [inspect](): string {
236
241
  return `Env(${this.#environment.context})`;
237
242
  }
@@ -354,6 +354,7 @@ export class TargetResolver {
354
354
  ),
355
355
  unstableSingleFileOutput:
356
356
  descriptor.__unstable_singleFileOutput,
357
+ customEnv: descriptor.env,
357
358
  }),
358
359
  };
359
360
 
package/src/types.ts CHANGED
@@ -84,6 +84,7 @@ export type Environment = {
84
84
  sourceMap: TargetSourceMapOptions | null | undefined;
85
85
  loc: InternalSourceLocation | null | undefined;
86
86
  unstableSingleFileOutput: boolean;
87
+ customEnv: EnvMap | null | undefined;
87
88
  };
88
89
 
89
90
  export type InternalSourceLocation = {
@@ -9,6 +9,7 @@ describe('Environment', () => {
9
9
  assert.deepEqual(fromEnvironmentId(createEnvironment()), {
10
10
  id: 'd821e85f6b50315e',
11
11
  context: 'browser',
12
+ customEnv: undefined,
12
13
  engines: {
13
14
  browsers: ['> 0.25%'],
14
15
  },
@@ -17,8 +18,8 @@ describe('Environment', () => {
17
18
  isLibrary: false,
18
19
  shouldOptimize: false,
19
20
  shouldScopeHoist: false,
20
- sourceMap: null,
21
- loc: null,
21
+ sourceMap: undefined,
22
+ loc: undefined,
22
23
  sourceType: 'module',
23
24
  unstableSingleFileOutput: false,
24
25
  });
@@ -30,6 +31,7 @@ describe('Environment', () => {
30
31
  {
31
32
  id: '2320af923a717577',
32
33
  context: 'node',
34
+ customEnv: undefined,
33
35
  engines: {
34
36
  node: '>= 10.0.0',
35
37
  },
@@ -54,6 +56,7 @@ describe('Environment', () => {
54
56
  {
55
57
  id: '75603271034eff15',
56
58
  context: 'browser',
59
+ customEnv: undefined,
57
60
  engines: {
58
61
  browsers: ['last 1 version'],
59
62
  },
@@ -62,8 +65,8 @@ describe('Environment', () => {
62
65
  isLibrary: false,
63
66
  shouldOptimize: false,
64
67
  shouldScopeHoist: false,
65
- sourceMap: null,
66
- loc: null,
68
+ sourceMap: undefined,
69
+ loc: undefined,
67
70
  sourceType: 'module',
68
71
  unstableSingleFileOutput: false,
69
72
  },
@@ -74,6 +77,7 @@ describe('Environment', () => {
74
77
  assert.deepEqual(fromEnvironmentId(createEnvironment({context: 'node'})), {
75
78
  id: 'e45cc12216f7857d',
76
79
  context: 'node',
80
+ customEnv: undefined,
77
81
  engines: {
78
82
  node: '>= 8.0.0',
79
83
  },
@@ -95,6 +99,7 @@ describe('Environment', () => {
95
99
  {
96
100
  id: 'd821e85f6b50315e',
97
101
  context: 'browser',
102
+ customEnv: undefined,
98
103
  engines: {
99
104
  browsers: ['> 0.25%'],
100
105
  },
@@ -103,8 +108,8 @@ describe('Environment', () => {
103
108
  isLibrary: false,
104
109
  shouldOptimize: false,
105
110
  shouldScopeHoist: false,
106
- sourceMap: null,
107
- loc: null,
111
+ sourceMap: undefined,
112
+ loc: undefined,
108
113
  sourceType: 'module',
109
114
  unstableSingleFileOutput: false,
110
115
  },
@@ -117,6 +122,7 @@ describe('Environment', () => {
117
122
  {
118
123
  id: '9917be65326c5de9',
119
124
  context: 'tesseract',
125
+ customEnv: undefined,
120
126
  engines: {
121
127
  browsers: ['> 0.25%'],
122
128
  },
@@ -125,8 +131,8 @@ describe('Environment', () => {
125
131
  isLibrary: false,
126
132
  shouldOptimize: false,
127
133
  shouldScopeHoist: false,
128
- sourceMap: null,
129
- loc: null,
134
+ sourceMap: undefined,
135
+ loc: undefined,
130
136
  sourceType: 'module',
131
137
  unstableSingleFileOutput: false,
132
138
  },