Skip to content
This repository was archived by the owner on May 17, 2022. It is now read-only.

Commit 6c96b4a

Browse files
authored
Merge pull request #34 from rajasegar/v4
BREAKING: migrate to ESM
2 parents 6b475a4 + d297b1b commit 6c96b4a

File tree

17 files changed

+11862
-1201
lines changed

17 files changed

+11862
-1201
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
node-version: [12.x]
15+
node-version: [14.x]
1616

1717
steps:
1818
- uses: actions/checkout@v1
@@ -24,12 +24,12 @@ jobs:
2424
run: |
2525
npm install
2626
npm test
27-
npm run coverage
27+
#npm run coverage
2828
29-
- name: Coveralls
30-
uses: coverallsapp/github-action@master
31-
with:
32-
github-token: ${{ secrets.GITHUB_TOKEN }}
29+
#- name: Coveralls
30+
# uses: coverallsapp/github-action@master
31+
# with:
32+
# github-token: ${{ secrets.GITHUB_TOKEN }}
3333

3434
- name: Release
3535
env:

.github/workflows/pull-requests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ jobs:
2020
run: |
2121
npm install
2222
npm test
23-
npm run coverage
23+
#npm run coverage
2424
25-
- name: Coveralls
26-
uses: coverallsapp/github-action@master
27-
with:
28-
github-token: ${{ secrets.GITHUB_TOKEN }}
25+
#- name: Coveralls
26+
# uses: coverallsapp/github-action@master
27+
# with:
28+
# github-token: ${{ secrets.GITHUB_TOKEN }}

babel.config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
presets: [['@babel/preset-env', {targets: {node: 'current'}}]],
3+
}

index.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
const core = require('./lib/core');
2-
const {
1+
import {
32
blockStatement,
43
callExpression,
54
expressionStatement,
@@ -10,11 +9,11 @@ const {
109
switchStatement,
1110
tryStatement,
1211
forStatement,
13-
} = core;
12+
} from './lib/core.js';
1413

15-
const jsx = require('./lib/jsx');
16-
const glimmer = require('./lib/glimmer-hbs');
17-
const es6 = require('./lib/es6');
14+
import * as jsx from './lib/jsx.js';
15+
import * as glimmer from './lib/glimmer-hbs.js';
16+
import * as es6 from './lib/es6.js';
1817

1918
function buildAST(ast, wrapExpression = true) {
2019

@@ -63,9 +62,8 @@ function buildAST(ast, wrapExpression = true) {
6362
return _ast;
6463
}
6564

66-
module.exports = {
65+
export {
6766
buildAST,
68-
core,
6967
es6,
7068
glimmer,
7169
jsx

jest.config.mjs

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
/*
2+
* For a detailed explanation regarding each configuration property, visit:
3+
* https://jestjs.io/docs/configuration
4+
*/
5+
6+
export default {
7+
// All imported modules in your tests should be mocked automatically
8+
// automock: false,
9+
10+
// Stop running tests after `n` failures
11+
// bail: 0,
12+
13+
// The directory where Jest should store its cached dependency information
14+
// cacheDirectory: "/private/var/folders/sy/psyb7ptj6jjbj3104ysp0b500000gn/T/jest_dx",
15+
16+
// Automatically clear mock calls, instances and results before every test
17+
clearMocks: true,
18+
19+
// Indicates whether the coverage information should be collected while executing the test
20+
collectCoverage: true,
21+
22+
// An array of glob patterns indicating a set of files for which coverage information should be collected
23+
// collectCoverageFrom: undefined,
24+
25+
// The directory where Jest should output its coverage files
26+
coverageDirectory: "coverage",
27+
28+
// An array of regexp pattern strings used to skip coverage collection
29+
// coveragePathIgnorePatterns: [
30+
// "/node_modules/"
31+
// ],
32+
33+
// Indicates which provider should be used to instrument code for coverage
34+
// coverageProvider: "babel",
35+
36+
// A list of reporter names that Jest uses when writing coverage reports
37+
// coverageReporters: [
38+
// "json",
39+
// "text",
40+
// "lcov",
41+
// "clover"
42+
// ],
43+
44+
// An object that configures minimum threshold enforcement for coverage results
45+
// coverageThreshold: undefined,
46+
47+
// A path to a custom dependency extractor
48+
// dependencyExtractor: undefined,
49+
50+
// Make calling deprecated APIs throw helpful error messages
51+
// errorOnDeprecated: false,
52+
53+
// Force coverage collection from ignored files using an array of glob patterns
54+
// forceCoverageMatch: [],
55+
56+
// A path to a module which exports an async function that is triggered once before all test suites
57+
// globalSetup: undefined,
58+
59+
// A path to a module which exports an async function that is triggered once after all test suites
60+
// globalTeardown: undefined,
61+
62+
// A set of global variables that need to be available in all test environments
63+
// globals: {},
64+
65+
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
66+
// maxWorkers: "50%",
67+
68+
// An array of directory names to be searched recursively up from the requiring module's location
69+
// moduleDirectories: [
70+
// "node_modules"
71+
// ],
72+
73+
// An array of file extensions your modules use
74+
// moduleFileExtensions: [
75+
// "js",
76+
// "jsx",
77+
// "ts",
78+
// "tsx",
79+
// "json",
80+
// "node"
81+
// ],
82+
83+
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
84+
// moduleNameMapper: {},
85+
86+
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
87+
// modulePathIgnorePatterns: [],
88+
89+
// Activates notifications for test results
90+
// notify: false,
91+
92+
// An enum that specifies notification mode. Requires { notify: true }
93+
// notifyMode: "failure-change",
94+
95+
// A preset that is used as a base for Jest's configuration
96+
// preset: undefined,
97+
98+
// Run tests from one or more projects
99+
// projects: undefined,
100+
101+
// Use this configuration option to add custom reporters to Jest
102+
// reporters: undefined,
103+
104+
// Automatically reset mock state before every test
105+
// resetMocks: false,
106+
107+
// Reset the module registry before running each individual test
108+
// resetModules: false,
109+
110+
// A path to a custom resolver
111+
// resolver: undefined,
112+
113+
// Automatically restore mock state and implementation before every test
114+
// restoreMocks: false,
115+
116+
// The root directory that Jest should scan for tests and modules within
117+
// rootDir: undefined,
118+
119+
// A list of paths to directories that Jest should use to search for files in
120+
// roots: [
121+
// "<rootDir>"
122+
// ],
123+
124+
// Allows you to use a custom runner instead of Jest's default test runner
125+
// runner: "jest-runner",
126+
127+
// The paths to modules that run some code to configure or set up the testing environment before each test
128+
// setupFiles: [],
129+
130+
// A list of paths to modules that run some code to configure or set up the testing framework before each test
131+
// setupFilesAfterEnv: [],
132+
133+
// The number of seconds after which a test is considered as slow and reported as such in the results.
134+
// slowTestThreshold: 5,
135+
136+
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
137+
// snapshotSerializers: [],
138+
139+
// The test environment that will be used for testing
140+
// testEnvironment: "jest-environment-node",
141+
142+
// Options that will be passed to the testEnvironment
143+
// testEnvironmentOptions: {},
144+
145+
// Adds a location field to test results
146+
// testLocationInResults: false,
147+
148+
// The glob patterns Jest uses to detect test files
149+
//testMatch: [
150+
//"**/__tests__/**/*.[jt]s?(x)",
151+
//"**/?(*.)+(spec|test).[tj]s?(x)",
152+
//],
153+
154+
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
155+
// testPathIgnorePatterns: [
156+
// "/node_modules/"
157+
// ],
158+
159+
// The regexp pattern or array of patterns that Jest uses to detect test files
160+
// testRegex: [],
161+
162+
// This option allows the use of a custom results processor
163+
// testResultsProcessor: undefined,
164+
165+
// This option allows use of a custom test runner
166+
// testRunner: "jest-circus/runner",
167+
168+
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
169+
// testURL: "http://localhost",
170+
171+
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
172+
// timers: "real",
173+
174+
// A map from regular expressions to paths to transformers
175+
transform: {
176+
"^.+\\.js$": "babel-jest",
177+
},
178+
179+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
180+
// transformIgnorePatterns: [
181+
// "/node_modules/",
182+
// "\\.pnp\\.[^\\/]+$"
183+
// ],
184+
185+
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
186+
// unmockedModulePathPatterns: undefined,
187+
188+
// Indicates whether each individual test should be reported during the run
189+
// verbose: undefined,
190+
191+
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
192+
// watchPathIgnorePatterns: [],
193+
194+
// Whether to use watchman for file crawling
195+
// watchman: true,
196+
};

lib/babel/base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function regExpLiteral(node) {
2424
return str;
2525
}
2626

27-
module.exports = {
27+
export {
2828
stringLiteral,
2929
numericLiteral,
3030
booleanLiteral,

lib/core.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const {
1+
import {
22
literal,
33
identifier,
44
breakStatement,
@@ -8,8 +8,7 @@ const {
88
unaryExpression,
99
buildCallee,
1010
buildElements
11-
} = require('./core/base');
12-
11+
} from './core/base.js';
1312

1413

1514

@@ -636,7 +635,7 @@ function forStatement(node) {
636635
}
637636

638637

639-
module.exports = {
638+
export {
640639
blockStatement,
641640
callExpression,
642641
memberExpression,

lib/core/base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function buildElements(elements) {
9393
}).join(',');
9494
}
9595

96-
module.exports = {
96+
export {
9797
literal,
9898
identifier,
9999
breakStatement,

lib/es6.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
const {
1+
import {
22
identifier,
33
breakStatement,
44
continueStatement,
55
buildCallee,
66
buildElements,
7-
} = require("./core/base");
7+
} from "./core/base.js";
88

9-
const {
9+
import {
1010
stringLiteral,
1111
numericLiteral,
1212
booleanLiteral,
1313
nullLiteral,
1414
regExpLiteral,
15-
} = require("./babel/base");
15+
} from "./babel/base.js";
1616

17-
const jsx = require("./jsx");
17+
import { element } from "./jsx.js";
1818

1919
function whileStatement(node) {
2020
let str = "";
@@ -585,7 +585,7 @@ function buildValue(node) {
585585
case "FunctionExpression":
586586
return functionExpression(node);
587587
case "JSXElement":
588-
return jsx.element(node);
588+
return element(node);
589589
case "UpdateExpression":
590590
return updateExpression(node);
591591
default:
@@ -686,7 +686,7 @@ function expressionStatement(node) {
686686
break;
687687

688688
case "JSXElement":
689-
str = jsx.element(expression);
689+
str = element(expression);
690690
break;
691691

692692
default:
@@ -1137,7 +1137,7 @@ function returnStatement(node) {
11371137
break;
11381138

11391139
case "JSXElement":
1140-
str = jsx.element(arg);
1140+
str = element(arg);
11411141
break;
11421142

11431143
default:
@@ -1398,7 +1398,7 @@ function buildAST(ast, wrapExpression = true) {
13981398
return blockStatement(node);
13991399

14001400
case "JSXElement":
1401-
return jsx.element(node);
1401+
return element(node);
14021402

14031403
default:
14041404
console.log("buildAST => ", node.type); // eslint-disable-line
@@ -1409,7 +1409,7 @@ function buildAST(ast, wrapExpression = true) {
14091409
return _ast;
14101410
}
14111411

1412-
module.exports = {
1412+
export {
14131413
buildAST,
14141414
spreadElement,
14151415
templateLiteral,

lib/glimmer-hbs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ function buildAST(ast) {
233233
return _ast;
234234
}
235235

236-
module.exports = {
236+
export {
237237
textNode,
238238
elementNode,
239239
buildAST

0 commit comments

Comments
 (0)