@atlaspack/core 2.12.1-canary.3464 → 2.12.1-canary.3466

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/lib/Atlaspack.js CHANGED
@@ -64,7 +64,7 @@ function _utils2() {
64
64
  };
65
65
  return data;
66
66
  }
67
- var _AtlaspackConfig = _interopRequireDefault(require("./AtlaspackConfig"));
67
+ var _AtlaspackConfig = require("./AtlaspackConfig");
68
68
  function _logger() {
69
69
  const data = _interopRequireDefault(require("@atlaspack/logger"));
70
70
  _logger = function () {
@@ -203,7 +203,7 @@ class Atlaspack {
203
203
  let {
204
204
  config
205
205
  } = await (0, _AtlaspackConfigRequest.loadAtlaspackConfig)(resolvedOptions);
206
- this.#config = new _AtlaspackConfig.default(config, resolvedOptions);
206
+ this.#config = new _AtlaspackConfig.AtlaspackConfig(config, resolvedOptions);
207
207
  if (this.#initialOptions.workerFarm) {
208
208
  if (this.#initialOptions.workerFarm.ending) {
209
209
  throw new Error('Supplied WorkerFarm is ending');
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.AtlaspackConfig = void 0;
7
7
  function _diagnostic() {
8
8
  const data = _interopRequireWildcard(require("@atlaspack/diagnostic"));
9
9
  _diagnostic = function () {
@@ -289,7 +289,7 @@ class AtlaspackConfig {
289
289
  });
290
290
  }
291
291
  }
292
- exports.default = AtlaspackConfig;
292
+ exports.AtlaspackConfig = AtlaspackConfig;
293
293
  function getConfigPaths(options, nodes) {
294
294
  return nodes.map(node => node !== '...' ? getConfigPath(options, node) : null).filter(Boolean);
295
295
  }
@@ -47,7 +47,7 @@ function _utils() {
47
47
  return data;
48
48
  }
49
49
  var _Dependency = require("./Dependency");
50
- var _AtlaspackConfig = _interopRequireDefault(require("./AtlaspackConfig"));
50
+ var _AtlaspackConfig = require("./AtlaspackConfig");
51
51
  var _PathRequest = require("./requests/PathRequest");
52
52
  var _Asset = require("./public/Asset");
53
53
  var _UncommittedAsset = _interopRequireDefault(require("./UncommittedAsset"));
package/lib/Validation.js CHANGED
@@ -32,7 +32,7 @@ function _diagnostic() {
32
32
  };
33
33
  return data;
34
34
  }
35
- var _AtlaspackConfig = _interopRequireDefault(require("./AtlaspackConfig"));
35
+ var _AtlaspackConfig = require("./AtlaspackConfig");
36
36
  var _UncommittedAsset = _interopRequireDefault(require("./UncommittedAsset"));
37
37
  var _assetUtils = require("./assetUtils");
38
38
  var _Asset = require("./public/Asset");
@@ -19,6 +19,7 @@ class MutableAsset {
19
19
  #inner;
20
20
  #ast;
21
21
  #contents;
22
+ #astDirty;
22
23
  get astGenerator() {
23
24
  throw new Error('get MutableAsset.astGenerator');
24
25
  }
@@ -47,6 +48,7 @@ class MutableAsset {
47
48
  this.#contents = Buffer.from(asset.code);
48
49
  this.fs = fs;
49
50
  this.env = env;
51
+ this.#astDirty = false;
50
52
  }
51
53
 
52
54
  // eslint-disable-next-line require-await
@@ -54,10 +56,11 @@ class MutableAsset {
54
56
  return this.#ast;
55
57
  }
56
58
  setAST(ast) {
59
+ this.#astDirty = true;
57
60
  this.#ast = ast;
58
61
  }
59
62
  isASTDirty() {
60
- throw new Error('MutableAsset.isASTDirty()');
63
+ return this.#astDirty;
61
64
  }
62
65
 
63
66
  // eslint-disable-next-line require-await
@@ -91,7 +94,8 @@ class MutableAsset {
91
94
  });
92
95
  }
93
96
  getMap() {
94
- throw new Error('MutableAsset.getMap');
97
+ // TODO: Provide source maps once they exist
98
+ return Promise.resolve(null);
95
99
  }
96
100
 
97
101
  // eslint-disable-next-line no-unused-vars
@@ -122,23 +126,23 @@ class MutableAsset {
122
126
 
123
127
  // eslint-disable-next-line no-unused-vars
124
128
  invalidateOnFileChange() {
125
- throw new Error('MutableAsset.invalidateOnFileChange()');
129
+ // TODO: Forward invalidations to Rust
126
130
  }
127
131
 
128
132
  // eslint-disable-next-line no-unused-vars
129
133
  invalidateOnFileCreate() {
130
- throw new Error('MutableAsset.invalidateOnFileCreate()');
134
+ // TODO: Forward invalidations to Rust
131
135
  }
132
136
 
133
137
  // eslint-disable-next-line no-unused-vars
134
138
  invalidateOnEnvChange() {
135
- throw new Error('MutableAsset.invalidateOnEnvChange()');
139
+ // TODO: Forward invalidations to Rust
136
140
  }
137
141
  invalidateOnStartup() {
138
- throw new Error('MutableAsset.invalidateOnStartup()');
142
+ // TODO: Forward invalidations to Rust
139
143
  }
140
144
  invalidateOnBuild() {
141
- throw new Error('MutableAsset.invalidateOnBuild()');
145
+ // TODO: Forward invalidations to Rust
142
146
  }
143
147
  }
144
148
  exports.MutableAsset = MutableAsset;
@@ -96,7 +96,7 @@ class AtlaspackWorker {
96
96
  dependency: napiDependency,
97
97
  specifier,
98
98
  pipeline,
99
- projectRoot
99
+ options
100
100
  }) => {
101
101
  const state = this.#resolvers.get(key);
102
102
  if (!state) {
@@ -104,7 +104,7 @@ class AtlaspackWorker {
104
104
  }
105
105
  let packageManager = state.packageManager;
106
106
  if (!packageManager) {
107
- packageManager = new (_packageManager().NodePackageManager)(this.#fs, projectRoot);
107
+ packageManager = new (_packageManager().NodePackageManager)(this.#fs, options.projectRoot);
108
108
  state.packageManager = packageManager;
109
109
  }
110
110
  const env = new _compat.Environment(napiDependency.env);
@@ -113,9 +113,9 @@ class AtlaspackWorker {
113
113
  logger: new _compat.PluginLogger(),
114
114
  tracer: new _compat.PluginTracer(),
115
115
  options: new _compat.PluginOptions({
116
+ ...options,
116
117
  packageManager,
117
118
  shouldAutoInstall: false,
118
- projectRoot,
119
119
  inputFS: this.#fs,
120
120
  outputFS: this.#fs
121
121
  })
@@ -164,7 +164,7 @@ class AtlaspackWorker {
164
164
  runTransformerTransform = (0, _jsCallable.jsCallable)(async ({
165
165
  key,
166
166
  env: napiEnv,
167
- projectRoot,
167
+ options,
168
168
  asset: innerAsset
169
169
  }) => {
170
170
  var _transformer$loadConf;
@@ -174,7 +174,7 @@ class AtlaspackWorker {
174
174
  }
175
175
  let packageManager = state.packageManager;
176
176
  if (!packageManager) {
177
- packageManager = new (_packageManager().NodePackageManager)(this.#fs, projectRoot);
177
+ packageManager = new (_packageManager().NodePackageManager)(this.#fs, options.projectRoot);
178
178
  state.packageManager = packageManager;
179
179
  }
180
180
  const transformer = state.transformer;
@@ -184,9 +184,9 @@ class AtlaspackWorker {
184
184
  logger: new _compat.PluginLogger(),
185
185
  tracer: new _compat.PluginTracer(),
186
186
  options: new _compat.PluginOptions({
187
+ ...options,
187
188
  packageManager,
188
189
  shouldAutoInstall: false,
189
- projectRoot,
190
190
  inputFS: this.#fs,
191
191
  outputFS: this.#fs
192
192
  })
@@ -222,21 +222,20 @@ class AtlaspackWorker {
222
222
  });
223
223
  if (transformer.generate) {
224
224
  const ast = await mutableAsset.getAST();
225
- if (!ast) {
226
- throw new Error('Transformer.generate.ast');
227
- }
228
- // $FlowFixMe "Cannot call `transformer.generate` because undefined [1] is not a function." 🤷‍♀️
229
- const output = await transformer.generate({
230
- asset: mutableAsset,
231
- ast,
232
- ...defaultOptions
233
- });
234
- if (typeof output.content === 'string') {
235
- mutableAsset.setCode(output.content);
236
- } else if (output.content instanceof Buffer) {
237
- mutableAsset.setBuffer(output.content);
238
- } else {
239
- mutableAsset.setStream(output.content);
225
+ if (ast) {
226
+ // $FlowFixMe "Cannot call `transformer.generate` because undefined [1] is not a function." 🤷‍♀️
227
+ const output = await transformer.generate({
228
+ asset: mutableAsset,
229
+ ast,
230
+ ...defaultOptions
231
+ });
232
+ if (typeof output.content === 'string') {
233
+ mutableAsset.setCode(output.content);
234
+ } else if (output.content instanceof Buffer) {
235
+ mutableAsset.setBuffer(output.content);
236
+ } else {
237
+ mutableAsset.setStream(output.content);
238
+ }
240
239
  }
241
240
  }
242
241
  (0, _assert().default)(result.length === 1, '[V3] Unimplemented: Multiple asset return from Node transformer');
@@ -14,7 +14,7 @@ function _graph() {
14
14
  var _serializer = require("./serializer");
15
15
  var _AssetGraph = _interopRequireDefault(require("./AssetGraph"));
16
16
  var _BundleGraph = _interopRequireDefault(require("./BundleGraph"));
17
- var _AtlaspackConfig = _interopRequireDefault(require("./AtlaspackConfig"));
17
+ var _AtlaspackConfig = require("./AtlaspackConfig");
18
18
  var _RequestTracker = require("./RequestTracker");
19
19
  var _Config = _interopRequireDefault(require("./public/Config"));
20
20
  var _package = _interopRequireDefault(require("../package.json"));
@@ -35,7 +35,7 @@ function registerCoreWithSerializer() {
35
35
  Config: _Config.default,
36
36
  BundleGraph: _BundleGraph.default,
37
37
  Graph: _graph().Graph,
38
- AtlaspackConfig: _AtlaspackConfig.default,
38
+ AtlaspackConfig: _AtlaspackConfig.AtlaspackConfig,
39
39
  RequestGraph: _RequestTracker.RequestGraph
40
40
  // $FlowFixMe[unclear-type]
41
41
  })) {
@@ -53,12 +53,12 @@ function _assert() {
53
53
  };
54
54
  return data;
55
55
  }
56
- var _AtlaspackConfig = _interopRequireDefault(require("../AtlaspackConfig.schema"));
57
- var _utils2 = require("../utils");
58
- var _AtlaspackConfig2 = _interopRequireDefault(require("../AtlaspackConfig"));
56
+ var _AtlaspackConfig = require("../AtlaspackConfig");
57
+ var _AtlaspackConfig2 = _interopRequireDefault(require("../AtlaspackConfig.schema"));
59
58
  var _buildCache = require("../buildCache");
60
59
  var _projectPath = require("../projectPath");
61
60
  var _RequestTracker = require("../RequestTracker");
61
+ var _utils2 = require("../utils");
62
62
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
63
63
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
64
64
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -113,7 +113,7 @@ function getCachedAtlaspackConfig(result, options) {
113
113
  if (config) {
114
114
  return config;
115
115
  }
116
- config = new _AtlaspackConfig2.default(processedConfig, options);
116
+ config = new _AtlaspackConfig.AtlaspackConfig(processedConfig, options);
117
117
  atlaspackConfigCache.set(cachePath, config);
118
118
  return config;
119
119
  }
@@ -396,7 +396,7 @@ function validateConfigFile(config, relativePath) {
396
396
  }
397
397
  });
398
398
  }
399
- _utils().validateSchema.diagnostic(_AtlaspackConfig.default, {
399
+ _utils().validateSchema.diagnostic(_AtlaspackConfig2.default, {
400
400
  data: config,
401
401
  filePath: relativePath
402
402
  }, '@atlaspack/core', 'Invalid Parcel Config');
@@ -43,7 +43,7 @@ function _utils() {
43
43
  var _ReporterRunner = require("../ReporterRunner");
44
44
  var _Dependency = require("../public/Dependency");
45
45
  var _PluginOptions = _interopRequireDefault(require("../public/PluginOptions"));
46
- var _AtlaspackConfig = _interopRequireDefault(require("../AtlaspackConfig"));
46
+ var _AtlaspackConfig = require("../AtlaspackConfig");
47
47
  var _AtlaspackConfigRequest = _interopRequireWildcard(require("./AtlaspackConfigRequest"));
48
48
  var _utils2 = require("../utils");
49
49
  var _projectPath = require("../projectPath");
@@ -11,7 +11,7 @@ function _nullthrows() {
11
11
  };
12
12
  return data;
13
13
  }
14
- var _AtlaspackConfig = _interopRequireDefault(require("../AtlaspackConfig"));
14
+ var _AtlaspackConfig = require("../AtlaspackConfig");
15
15
  var _ReporterRunner = require("../ReporterRunner");
16
16
  var _Validation = _interopRequireDefault(require("../Validation"));
17
17
  var _AtlaspackConfigRequest = _interopRequireDefault(require("./AtlaspackConfigRequest"));
@@ -34,7 +34,7 @@ function createValidationRequest(input) {
34
34
  config: processedConfig,
35
35
  cachePath
36
36
  } = (0, _nullthrows().default)(await api.runRequest((0, _AtlaspackConfigRequest.default)()));
37
- let config = new _AtlaspackConfig.default(processedConfig, options);
37
+ let config = new _AtlaspackConfig.AtlaspackConfig(processedConfig, options);
38
38
  let trackedRequestsDesc = assetRequests.filter(request => {
39
39
  return config.getValidatorNames(request.filePath).length > 0;
40
40
  });
@@ -45,7 +45,7 @@ function _logger() {
45
45
  return data;
46
46
  }
47
47
  var _DevDepRequest = require("./DevDepRequest");
48
- var _AtlaspackConfig = _interopRequireDefault(require("../AtlaspackConfig"));
48
+ var _AtlaspackConfig = require("../AtlaspackConfig");
49
49
  function _diagnostic() {
50
50
  const data = _interopRequireWildcard(require("@atlaspack/diagnostic"));
51
51
  _diagnostic = function () {
package/lib/worker.js CHANGED
@@ -35,7 +35,7 @@ var _Transformation = _interopRequireDefault(require("./Transformation"));
35
35
  var _ReporterRunner = require("./ReporterRunner");
36
36
  var _PackagerRunner = _interopRequireDefault(require("./PackagerRunner"));
37
37
  var _Validation = _interopRequireDefault(require("./Validation"));
38
- var _AtlaspackConfig = _interopRequireDefault(require("./AtlaspackConfig"));
38
+ var _AtlaspackConfig = require("./AtlaspackConfig");
39
39
  var _registerCoreWithSerializer = require("./registerCoreWithSerializer");
40
40
  var _buildCache = require("./buildCache");
41
41
  function _sourceMap() {
@@ -98,7 +98,7 @@ async function loadConfig(cachePath, options) {
98
98
  return config;
99
99
  }
100
100
  let processedConfig = (0, _nullthrows().default)(await options.cache.get(cachePath));
101
- config = new _AtlaspackConfig.default(processedConfig, options);
101
+ config = new _AtlaspackConfig.AtlaspackConfig(processedConfig, options);
102
102
  atlaspackConfigCache.set(cachePath, config);
103
103
  (0, _featureFlags().setFeatureFlags)(options.featureFlags);
104
104
  return config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.12.1-canary.3464+b66723585",
3
+ "version": "2.12.1-canary.3466+f92a71f3e",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -20,20 +20,20 @@
20
20
  "check-ts": "tsc --noEmit index.d.ts"
21
21
  },
22
22
  "dependencies": {
23
- "@atlaspack/cache": "2.12.1-canary.3464+b66723585",
24
- "@atlaspack/diagnostic": "2.12.1-canary.3464+b66723585",
25
- "@atlaspack/events": "2.12.1-canary.3464+b66723585",
26
- "@atlaspack/feature-flags": "2.12.1-canary.3464+b66723585",
27
- "@atlaspack/fs": "2.12.1-canary.3464+b66723585",
28
- "@atlaspack/graph": "3.2.1-canary.3464+b66723585",
29
- "@atlaspack/logger": "2.12.1-canary.3464+b66723585",
30
- "@atlaspack/package-manager": "2.12.1-canary.3464+b66723585",
31
- "@atlaspack/plugin": "2.12.1-canary.3464+b66723585",
32
- "@atlaspack/profiler": "2.12.1-canary.3464+b66723585",
33
- "@atlaspack/rust": "2.12.1-canary.3464+b66723585",
34
- "@atlaspack/types": "2.12.1-canary.3464+b66723585",
35
- "@atlaspack/utils": "2.12.1-canary.3464+b66723585",
36
- "@atlaspack/workers": "2.12.1-canary.3464+b66723585",
23
+ "@atlaspack/cache": "2.12.1-canary.3466+f92a71f3e",
24
+ "@atlaspack/diagnostic": "2.12.1-canary.3466+f92a71f3e",
25
+ "@atlaspack/events": "2.12.1-canary.3466+f92a71f3e",
26
+ "@atlaspack/feature-flags": "2.12.1-canary.3466+f92a71f3e",
27
+ "@atlaspack/fs": "2.12.1-canary.3466+f92a71f3e",
28
+ "@atlaspack/graph": "3.2.1-canary.3466+f92a71f3e",
29
+ "@atlaspack/logger": "2.12.1-canary.3466+f92a71f3e",
30
+ "@atlaspack/package-manager": "2.12.1-canary.3466+f92a71f3e",
31
+ "@atlaspack/plugin": "2.12.1-canary.3466+f92a71f3e",
32
+ "@atlaspack/profiler": "2.12.1-canary.3466+f92a71f3e",
33
+ "@atlaspack/rust": "2.12.1-canary.3466+f92a71f3e",
34
+ "@atlaspack/types": "2.12.1-canary.3466+f92a71f3e",
35
+ "@atlaspack/utils": "2.12.1-canary.3466+f92a71f3e",
36
+ "@atlaspack/workers": "2.12.1-canary.3466+f92a71f3e",
37
37
  "@mischnic/json-sourcemap": "^0.1.0",
38
38
  "@parcel/source-map": "^2.1.1",
39
39
  "base-x": "^3.0.8",
@@ -64,5 +64,5 @@
64
64
  "browser": {
65
65
  "./src/serializerCore.js": "./src/serializerCore.browser.js"
66
66
  },
67
- "gitHead": "b667235859922e485011908e0d4069ab95598be5"
67
+ "gitHead": "f92a71f3e7673b1c0c89ec4c3345f8ae10325275"
68
68
  }
package/src/Atlaspack.js CHANGED
@@ -31,7 +31,7 @@ import resolveOptions from './resolveOptions';
31
31
  import {ValueEmitter} from '@atlaspack/events';
32
32
  import {registerCoreWithSerializer} from './registerCoreWithSerializer';
33
33
  import {PromiseQueue} from '@atlaspack/utils';
34
- import AtlaspackConfig from './AtlaspackConfig';
34
+ import {AtlaspackConfig} from './AtlaspackConfig';
35
35
  import logger from '@atlaspack/logger';
36
36
  import RequestTracker, {
37
37
  getWatcherOptions,
@@ -55,7 +55,7 @@ export type LoadedPlugin<T> = {|
55
55
  range?: ?SemverRange,
56
56
  |};
57
57
 
58
- export default class AtlaspackConfig {
58
+ export class AtlaspackConfig {
59
59
  options: AtlaspackOptions;
60
60
  filePath: ProjectPath;
61
61
  resolvers: PureAtlaspackConfigPipeline;
@@ -18,7 +18,7 @@ import type {
18
18
  ReportFn,
19
19
  RequestInvalidation,
20
20
  } from './types';
21
- import type AtlaspackConfig, {LoadedPlugin} from './AtlaspackConfig';
21
+ import type {AtlaspackConfig, LoadedPlugin} from './AtlaspackConfig';
22
22
  import type InternalBundleGraph from './BundleGraph';
23
23
  import type {ConfigRequest} from './requests/ConfigRequest';
24
24
  import type {DevDepSpecifier} from './requests/DevDepRequest';
@@ -35,7 +35,7 @@ import ThrowableDiagnostic, {
35
35
  import {SOURCEMAP_EXTENSIONS} from '@atlaspack/utils';
36
36
 
37
37
  import {createDependency} from './Dependency';
38
- import AtlaspackConfig from './AtlaspackConfig';
38
+ import {AtlaspackConfig} from './AtlaspackConfig';
39
39
  // TODO: eventually call path request as sub requests
40
40
  import {ResolverRunner} from './requests/PathRequest';
41
41
  import {
package/src/Validation.js CHANGED
@@ -9,7 +9,7 @@ import path from 'path';
9
9
  import {resolveConfig} from '@atlaspack/utils';
10
10
  import logger, {PluginLogger} from '@atlaspack/logger';
11
11
  import ThrowableDiagnostic, {errorToDiagnostic} from '@atlaspack/diagnostic';
12
- import AtlaspackConfig from './AtlaspackConfig';
12
+ import {AtlaspackConfig} from './AtlaspackConfig';
13
13
  import UncommittedAsset from './UncommittedAsset';
14
14
  import {createAsset} from './assetUtils';
15
15
  import {Asset} from './public/Asset';
@@ -11,7 +11,7 @@ import type {
11
11
  DevDepRequest,
12
12
  AtlaspackOptions,
13
13
  } from './types';
14
- import type AtlaspackConfig from './AtlaspackConfig';
14
+ import type {AtlaspackConfig} from './AtlaspackConfig';
15
15
  import type PluginOptions from './public/PluginOptions';
16
16
  import type {RequestResult, RunAPI} from './RequestTracker';
17
17
 
@@ -43,6 +43,7 @@ export class MutableAsset implements IMutableAsset {
43
43
  #inner: InnerAsset;
44
44
  #ast: ?AST;
45
45
  #contents: Buffer;
46
+ #astDirty: boolean;
46
47
 
47
48
  get astGenerator(): ?ASTGenerator {
48
49
  throw new Error('get MutableAsset.astGenerator');
@@ -74,6 +75,7 @@ export class MutableAsset implements IMutableAsset {
74
75
  this.#contents = Buffer.from(asset.code);
75
76
  this.fs = fs;
76
77
  this.env = env;
78
+ this.#astDirty = false;
77
79
  }
78
80
 
79
81
  // eslint-disable-next-line require-await
@@ -82,11 +84,12 @@ export class MutableAsset implements IMutableAsset {
82
84
  }
83
85
 
84
86
  setAST(ast: AST): void {
87
+ this.#astDirty = true;
85
88
  this.#ast = ast;
86
89
  }
87
90
 
88
91
  isASTDirty(): boolean {
89
- throw new Error('MutableAsset.isASTDirty()');
92
+ return this.#astDirty;
90
93
  }
91
94
 
92
95
  // eslint-disable-next-line require-await
@@ -128,7 +131,8 @@ export class MutableAsset implements IMutableAsset {
128
131
  }
129
132
 
130
133
  getMap(): Promise<?SourceMap> {
131
- throw new Error('MutableAsset.getMap');
134
+ // TODO: Provide source maps once they exist
135
+ return Promise.resolve(null);
132
136
  }
133
137
 
134
138
  // eslint-disable-next-line no-unused-vars
@@ -161,24 +165,24 @@ export class MutableAsset implements IMutableAsset {
161
165
 
162
166
  // eslint-disable-next-line no-unused-vars
163
167
  invalidateOnFileChange(invalidation: FilePath): void {
164
- throw new Error('MutableAsset.invalidateOnFileChange()');
168
+ // TODO: Forward invalidations to Rust
165
169
  }
166
170
 
167
171
  // eslint-disable-next-line no-unused-vars
168
172
  invalidateOnFileCreate(invalidation: FileCreateInvalidation): void {
169
- throw new Error('MutableAsset.invalidateOnFileCreate()');
173
+ // TODO: Forward invalidations to Rust
170
174
  }
171
175
 
172
176
  // eslint-disable-next-line no-unused-vars
173
177
  invalidateOnEnvChange(invalidation: string): void {
174
- throw new Error('MutableAsset.invalidateOnEnvChange()');
178
+ // TODO: Forward invalidations to Rust
175
179
  }
176
180
 
177
181
  invalidateOnStartup(): void {
178
- throw new Error('MutableAsset.invalidateOnStartup()');
182
+ // TODO: Forward invalidations to Rust
179
183
  }
180
184
 
181
185
  invalidateOnBuild(): void {
182
- throw new Error('MutableAsset.invalidateOnBuild()');
186
+ // TODO: Forward invalidations to Rust
183
187
  }
184
188
  }
@@ -76,13 +76,7 @@ export class AtlaspackWorker {
76
76
  [RunResolverResolveOptions],
77
77
  Promise<RunResolverResolveResult>,
78
78
  > = jsCallable(
79
- async ({
80
- key,
81
- dependency: napiDependency,
82
- specifier,
83
- pipeline,
84
- projectRoot,
85
- }) => {
79
+ async ({key, dependency: napiDependency, specifier, pipeline, options}) => {
86
80
  const state = this.#resolvers.get(key);
87
81
  if (!state) {
88
82
  throw new Error(`Resolver not found: ${key}`);
@@ -90,7 +84,7 @@ export class AtlaspackWorker {
90
84
 
91
85
  let packageManager = state.packageManager;
92
86
  if (!packageManager) {
93
- packageManager = new NodePackageManager(this.#fs, projectRoot);
87
+ packageManager = new NodePackageManager(this.#fs, options.projectRoot);
94
88
  state.packageManager = packageManager;
95
89
  }
96
90
 
@@ -101,9 +95,9 @@ export class AtlaspackWorker {
101
95
  logger: new PluginLogger(),
102
96
  tracer: new PluginTracer(),
103
97
  options: new PluginOptions({
98
+ ...options,
104
99
  packageManager,
105
100
  shouldAutoInstall: false,
106
- projectRoot,
107
101
  inputFS: this.#fs,
108
102
  outputFS: this.#fs,
109
103
  }),
@@ -155,71 +149,68 @@ export class AtlaspackWorker {
155
149
  runTransformerTransform: JsCallable<
156
150
  [RunTransformerTransformOptions],
157
151
  Promise<RunTransformerTransformResult>,
158
- > = jsCallable(
159
- async ({key, env: napiEnv, projectRoot, asset: innerAsset}) => {
160
- const state = this.#transformers.get(key);
161
- if (!state) {
162
- throw new Error(`Transformer not found: ${key}`);
163
- }
164
-
165
- let packageManager = state.packageManager;
166
- if (!packageManager) {
167
- packageManager = new NodePackageManager(this.#fs, projectRoot);
168
- state.packageManager = packageManager;
169
- }
170
-
171
- const transformer: Transformer<any> = state.transformer;
172
- const env = new Environment(napiEnv);
173
- const mutableAsset = new MutableAsset(innerAsset, this.#fs, env);
174
- const defaultOptions = {
175
- logger: new PluginLogger(),
176
- tracer: new PluginTracer(),
177
- options: new PluginOptions({
178
- packageManager,
179
- shouldAutoInstall: false,
180
- projectRoot,
181
- inputFS: this.#fs,
182
- outputFS: this.#fs,
183
- }),
184
- };
185
-
186
- const config = await transformer.loadConfig?.({
187
- config: new PluginConfig({
188
- env,
189
- isSource: true,
190
- searchPath: '',
191
- }),
192
- ...defaultOptions,
193
- });
194
-
195
- if (transformer.parse) {
196
- const ast = await transformer.parse({
197
- asset: mutableAsset,
198
- config,
199
- get resolve() {
200
- throw new Error('Transformer.parse.resolve()');
201
- },
202
- ...defaultOptions,
203
- });
204
- if (ast) {
205
- mutableAsset.setAST(ast);
206
- }
207
- }
208
-
209
- const result = await state.transformer.transform({
152
+ > = jsCallable(async ({key, env: napiEnv, options, asset: innerAsset}) => {
153
+ const state = this.#transformers.get(key);
154
+ if (!state) {
155
+ throw new Error(`Transformer not found: ${key}`);
156
+ }
157
+
158
+ let packageManager = state.packageManager;
159
+ if (!packageManager) {
160
+ packageManager = new NodePackageManager(this.#fs, options.projectRoot);
161
+ state.packageManager = packageManager;
162
+ }
163
+
164
+ const transformer: Transformer<any> = state.transformer;
165
+ const env = new Environment(napiEnv);
166
+ const mutableAsset = new MutableAsset(innerAsset, this.#fs, env);
167
+ const defaultOptions = {
168
+ logger: new PluginLogger(),
169
+ tracer: new PluginTracer(),
170
+ options: new PluginOptions({
171
+ ...options,
172
+ packageManager,
173
+ shouldAutoInstall: false,
174
+ inputFS: this.#fs,
175
+ outputFS: this.#fs,
176
+ }),
177
+ };
178
+
179
+ const config = await transformer.loadConfig?.({
180
+ config: new PluginConfig({
181
+ env,
182
+ isSource: true,
183
+ searchPath: '',
184
+ }),
185
+ ...defaultOptions,
186
+ });
187
+
188
+ if (transformer.parse) {
189
+ const ast = await transformer.parse({
210
190
  asset: mutableAsset,
211
191
  config,
212
192
  get resolve() {
213
- throw new Error('Transformer.transform.resolve()');
193
+ throw new Error('Transformer.parse.resolve()');
214
194
  },
215
195
  ...defaultOptions,
216
196
  });
217
-
218
- if (transformer.generate) {
219
- const ast = await mutableAsset.getAST();
220
- if (!ast) {
221
- throw new Error('Transformer.generate.ast');
222
- }
197
+ if (ast) {
198
+ mutableAsset.setAST(ast);
199
+ }
200
+ }
201
+
202
+ const result = await state.transformer.transform({
203
+ asset: mutableAsset,
204
+ config,
205
+ get resolve() {
206
+ throw new Error('Transformer.transform.resolve()');
207
+ },
208
+ ...defaultOptions,
209
+ });
210
+
211
+ if (transformer.generate) {
212
+ const ast = await mutableAsset.getAST();
213
+ if (ast) {
223
214
  // $FlowFixMe "Cannot call `transformer.generate` because undefined [1] is not a function." 🤷‍♀️
224
215
  const output = await transformer.generate({
225
216
  asset: mutableAsset,
@@ -235,38 +226,38 @@ export class AtlaspackWorker {
235
226
  mutableAsset.setStream(output.content);
236
227
  }
237
228
  }
238
-
239
- assert(
240
- result.length === 1,
241
- '[V3] Unimplemented: Multiple asset return from Node transformer',
242
- );
243
-
244
- assert(
245
- result[0] === mutableAsset,
246
- '[V3] Unimplemented: New asset returned from Node transformer',
247
- );
248
-
249
- return {
250
- asset: {
251
- id: mutableAsset.id,
252
- bundleBehavior: bundleBehaviorMap.intoNullable(
253
- mutableAsset.bundleBehavior,
254
- ),
255
- filePath: mutableAsset.filePath,
256
- type: mutableAsset.type,
257
- code: Array.from(await mutableAsset.getBuffer()),
258
- meta: mutableAsset.meta,
259
- pipeline: mutableAsset.pipeline,
260
- query: mutableAsset.query.toString(),
261
- symbols: mutableAsset.symbols.intoNapi(),
262
- uniqueKey: mutableAsset.uniqueKey,
263
- sideEffects: mutableAsset.sideEffects,
264
- isBundleSplittable: mutableAsset.isBundleSplittable,
265
- isSource: mutableAsset.isSource,
266
- },
267
- };
268
- },
269
- );
229
+ }
230
+
231
+ assert(
232
+ result.length === 1,
233
+ '[V3] Unimplemented: Multiple asset return from Node transformer',
234
+ );
235
+
236
+ assert(
237
+ result[0] === mutableAsset,
238
+ '[V3] Unimplemented: New asset returned from Node transformer',
239
+ );
240
+
241
+ return {
242
+ asset: {
243
+ id: mutableAsset.id,
244
+ bundleBehavior: bundleBehaviorMap.intoNullable(
245
+ mutableAsset.bundleBehavior,
246
+ ),
247
+ filePath: mutableAsset.filePath,
248
+ type: mutableAsset.type,
249
+ code: Array.from(await mutableAsset.getBuffer()),
250
+ meta: mutableAsset.meta,
251
+ pipeline: mutableAsset.pipeline,
252
+ query: mutableAsset.query.toString(),
253
+ symbols: mutableAsset.symbols.intoNapi(),
254
+ uniqueKey: mutableAsset.uniqueKey,
255
+ sideEffects: mutableAsset.sideEffects,
256
+ isBundleSplittable: mutableAsset.isBundleSplittable,
257
+ isSource: mutableAsset.isSource,
258
+ },
259
+ };
260
+ });
270
261
  }
271
262
 
272
263
  napi.registerWorker(workerData.tx_worker, new AtlaspackWorker());
@@ -288,12 +279,17 @@ type LoadPluginOptions = {|
288
279
  resolveFrom: string,
289
280
  |};
290
281
 
282
+ type RpcPluginOptions = {|
283
+ projectRoot: string,
284
+ mode: string,
285
+ |};
286
+
291
287
  type RunResolverResolveOptions = {|
292
288
  key: string,
293
289
  dependency: napi.Dependency,
294
290
  specifier: FilePath,
295
291
  pipeline: ?string,
296
- projectRoot: string,
292
+ options: RpcPluginOptions,
297
293
  |};
298
294
 
299
295
  type RunResolverResolveResult = {|
@@ -317,7 +313,7 @@ type RunResolverResolveResult = {|
317
313
  type RunTransformerTransformOptions = {|
318
314
  key: string,
319
315
  env: napi.Environment,
320
- projectRoot: string,
316
+ options: RpcPluginOptions,
321
317
  asset: napi.Asset,
322
318
  |};
323
319
 
@@ -3,7 +3,7 @@ import {Graph} from '@atlaspack/graph';
3
3
  import {registerSerializableClass} from './serializer';
4
4
  import AssetGraph from './AssetGraph';
5
5
  import BundleGraph from './BundleGraph';
6
- import AtlaspackConfig from './AtlaspackConfig';
6
+ import {AtlaspackConfig} from './AtlaspackConfig';
7
7
  import {RequestGraph} from './RequestTracker';
8
8
  import Config from './public/Config';
9
9
  import packageJson from '../package.json';
@@ -33,12 +33,12 @@ import {parse} from 'json5';
33
33
  import path from 'path';
34
34
  import invariant from 'assert';
35
35
 
36
+ import {AtlaspackConfig} from '../AtlaspackConfig';
36
37
  import AtlaspackConfigSchema from '../AtlaspackConfig.schema';
37
- import {optionsProxy} from '../utils';
38
- import AtlaspackConfig from '../AtlaspackConfig';
39
38
  import {createBuildCache} from '../buildCache';
40
39
  import {toProjectPath} from '../projectPath';
41
40
  import {requestTypes} from '../RequestTracker';
41
+ import {optionsProxy} from '../utils';
42
42
 
43
43
  type ConfigMap<K, V> = {[K]: V, ...};
44
44
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  import type {Async, Bundle as IBundle, Namer} from '@atlaspack/types';
4
4
  import type {SharedReference} from '@atlaspack/workers';
5
- import type AtlaspackConfig, {LoadedPlugin} from '../AtlaspackConfig';
5
+ import type {AtlaspackConfig, LoadedPlugin} from '../AtlaspackConfig';
6
6
  import type {StaticRunOpts, RunAPI} from '../RequestTracker';
7
7
  import type {
8
8
  Asset,
@@ -4,7 +4,7 @@ import type {
4
4
  SemverRange,
5
5
  Invalidations,
6
6
  } from '@atlaspack/types';
7
- import type AtlaspackConfig from '../AtlaspackConfig';
7
+ import type {AtlaspackConfig} from '../AtlaspackConfig';
8
8
  import type {
9
9
  DevDepRequest,
10
10
  AtlaspackOptions,
@@ -28,7 +28,7 @@ import {normalizePath} from '@atlaspack/utils';
28
28
  import {report} from '../ReporterRunner';
29
29
  import {getPublicDependency} from '../public/Dependency';
30
30
  import PluginOptions from '../public/PluginOptions';
31
- import AtlaspackConfig from '../AtlaspackConfig';
31
+ import {AtlaspackConfig, type LoadedPlugin} from '../AtlaspackConfig';
32
32
  import createAtlaspackConfigRequest, {
33
33
  getCachedAtlaspackConfig,
34
34
  } from './AtlaspackConfigRequest';
@@ -41,7 +41,6 @@ import {
41
41
  } from '../projectPath';
42
42
  import {Priority} from '../types';
43
43
  import {createBuildCache} from '../buildCache';
44
- import type {LoadedPlugin} from '../AtlaspackConfig';
45
44
  import {createConfig} from '../InternalConfig';
46
45
  import {loadPluginConfig, runConfigRequest} from './ConfigRequest';
47
46
  import {
@@ -6,7 +6,7 @@ import type {AssetGroup} from '../types';
6
6
  import type {ConfigAndCachePath} from './AtlaspackConfigRequest';
7
7
 
8
8
  import nullthrows from 'nullthrows';
9
- import AtlaspackConfig from '../AtlaspackConfig';
9
+ import {AtlaspackConfig} from '../AtlaspackConfig';
10
10
  import {report} from '../ReporterRunner';
11
11
  import Validation from '../Validation';
12
12
  import createAtlaspackConfigRequest from './AtlaspackConfigRequest';
@@ -36,7 +36,7 @@ import {
36
36
  createDevDependency,
37
37
  runDevDepRequest,
38
38
  } from './DevDepRequest';
39
- import AtlaspackConfig from '../AtlaspackConfig';
39
+ import {AtlaspackConfig} from '../AtlaspackConfig';
40
40
  import ThrowableDiagnostic, {errorToDiagnostic} from '@atlaspack/diagnostic';
41
41
  import {PluginTracer, tracer} from '@atlaspack/profiler';
42
42
  import {requestTypes} from '../RequestTracker';
package/src/worker.js CHANGED
@@ -20,7 +20,7 @@ import Transformation, {
20
20
  import {reportWorker, report} from './ReporterRunner';
21
21
  import PackagerRunner, {type RunPackagerRunnerResult} from './PackagerRunner';
22
22
  import Validation, {type ValidationOpts} from './Validation';
23
- import AtlaspackConfig from './AtlaspackConfig';
23
+ import {AtlaspackConfig} from './AtlaspackConfig';
24
24
  import {registerCoreWithSerializer} from './registerCoreWithSerializer';
25
25
  import {clearBuildCaches} from './buildCache';
26
26
  import {init as initSourcemaps} from '@parcel/source-map';
@@ -1,14 +1,17 @@
1
1
  // @flow strict-local
2
2
 
3
- import AtlaspackConfig from '../src/AtlaspackConfig';
4
3
  import assert from 'assert';
5
4
  import path from 'path';
6
- import sinon from 'sinon';
5
+
7
6
  import logger from '@atlaspack/logger';
8
7
  import {inputFS} from '@atlaspack/test-utils';
8
+ import sinon from 'sinon';
9
+
10
+ import {AtlaspackConfig} from '../src/AtlaspackConfig';
11
+ import {toProjectPath} from '../src/projectPath';
9
12
  import {parseAndProcessConfig} from '../src/requests/AtlaspackConfigRequest';
13
+
10
14
  import {DEFAULT_OPTIONS} from './test-utils';
11
- import {toProjectPath} from '../src/projectPath';
12
15
 
13
16
  const ATLASPACKRC_PATH = toProjectPath('/', '/.parcelrc');
14
17
 
@@ -1,8 +1,11 @@
1
1
  // @flow
2
2
  import assert from 'assert';
3
- import nullthrows from 'nullthrows';
4
3
  import path from 'path';
5
- import AtlaspackConfig from '../src/AtlaspackConfig';
4
+
5
+ import nullthrows from 'nullthrows';
6
+
7
+ import {AtlaspackConfig} from '../src/AtlaspackConfig';
8
+ import {toProjectPath} from '../src/projectPath';
6
9
  import {
7
10
  validateConfigFile,
8
11
  mergePipelines,
@@ -13,8 +16,8 @@ import {
13
16
  resolveAtlaspackConfig,
14
17
  processConfig,
15
18
  } from '../src/requests/AtlaspackConfigRequest';
19
+
16
20
  import {DEFAULT_OPTIONS, relative} from './test-utils';
17
- import {toProjectPath} from '../src/projectPath';
18
21
 
19
22
  describe('AtlaspackConfigRequest', () => {
20
23
  describe('validateConfigFile', () => {