Skip to content

Commit 293b6af

Browse files
committed
fix: CJS build issue fix
Without this anything that uses ember-cli-addon-docs then explodes with: ``` require() of ES Module /Users/michal/ember/ember-intl/node_modules/.pnpm/@handlebars+parser@file+..+handlebars-parser/node_modules/@handlebars/parser/dist/cjs/index.js not supported. Instead change the require of index.js in null to a dynamic import() which is available in all CommonJS modules. ```
1 parent fbdebfb commit 293b6af

File tree

4 files changed

+34
-22
lines changed

4 files changed

+34
-22
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
"lint": "eslint .",
3737
"prepublishOnly": "pnpm run build",
3838
"build": "npm-run-all build:parser build:esm build:cjs",
39-
"build:cjs": "tsc --module nodenext --moduleResolution nodenext --target es5 --outDir dist/cjs",
40-
"build:esm": "tsc --module es2015 --target es5 --outDir dist/esm",
39+
"build:cjs": "tsc --project tsconfig.cjs.json",
40+
"build:esm": "tsc --project tsconfig.esm.json",
4141
"build:jison": "jison -m js src/handlebars.yy src/handlebars.l -o lib/parser.js",
4242
"build:parser": "npm-run-all build:jison build:parser-suffix",
4343
"build:parser-suffix": "combine-files lib/parser.js,src/parser-suffix.js lib/parser.js",
Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,21 @@
11
{
22
"compilerOptions": {
3-
// Compilation Configuration
43
"target": "es2017",
5-
"inlineSources": true,
6-
"inlineSourceMap": true,
7-
"outDir": "dist",
8-
"baseUrl": "lib",
9-
"rootDir": "lib",
104
"esModuleInterop": true,
11-
"moduleResolution": "bundler",
12-
"verbatimModuleSyntax": true,
13-
// Enhance Strictness
5+
"moduleResolution": "node",
146
"strict": true,
157
"suppressImplicitAnyIndexErrors": false,
168
"noUnusedLocals": true,
179
"noUnusedParameters": true,
1810
"noImplicitReturns": true,
1911
"newLine": "LF",
20-
"allowJs": true
12+
"allowJs": true,
13+
"inlineSources": true,
14+
"inlineSourceMap": true,
15+
"baseUrl": "lib",
16+
"rootDir": "lib",
17+
"verbatimModuleSyntax": true
2118
},
22-
"include": [
23-
"lib/**/*.js",
24-
"lib/**/*.d.ts"
25-
],
26-
"exclude": [
27-
"dist",
28-
"node_modules",
29-
".vscode"
30-
]
31-
}
19+
"include": ["lib/**/*.js", "lib/**/*.d.ts"],
20+
"exclude": ["dist", "node_modules", ".vscode"]
21+
}

tsconfig.cjs.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
"outDir": "dist/cjs",
6+
"declaration": false,
7+
"allowJs": true
8+
},
9+
"include": ["lib/**/*.js", "lib/**/*.ts"],
10+
"exclude": ["dist", "node_modules", ".vscode"]
11+
}

tsconfig.esm.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "esnext",
5+
"outDir": "dist/esm",
6+
"declaration": false,
7+
"allowJs": true
8+
},
9+
"include": ["lib/**/*.js"],
10+
"exclude": ["dist", "node_modules", ".vscode"]
11+
}

0 commit comments

Comments
 (0)