json-as 0.5.21 → 0.5.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-as",
3
- "version": "0.5.21",
3
+ "version": "0.5.22",
4
4
  "description": "JSON encoder/decoder for AssemblyScript",
5
5
  "types": "assembly/index.ts",
6
6
  "author": "Jairus Tanaka",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@json-as/transform",
3
- "version": "0.5.21",
3
+ "version": "0.5.22",
4
4
  "description": "JSON encoder/decoder for AssemblyScript",
5
5
  "main": "./lib/index.js",
6
6
  "author": "Jairus Tanaka",
@@ -149,8 +149,22 @@ export default class Transformer extends Transform {
149
149
  afterParse(parser: Parser): void {
150
150
  // Create new transform
151
151
  const transformer = new AsJSONTransform();
152
+
153
+ // Sort the sources so that user scripts are visited last
154
+ const sources = parser.sources.filter(source => !isStdlib(source)).sort((_a, _b) => {
155
+ const a = _a.internalPath
156
+ const b = _b.internalPath
157
+ if (a[0] === "~" && b[0] !== "~") {
158
+ return -1;
159
+ } else if (a[0] !== "~" && b[0] === "~") {
160
+ return 1;
161
+ } else {
162
+ return 0;
163
+ }
164
+ })
165
+
152
166
  // Loop over every source
153
- for (const source of parser.sources) {
167
+ for (const source of sources) {
154
168
  // Ignore all lib and std. Visit everything else.
155
169
  if (!isStdlib(source)) {
156
170
  transformer.visit(source);