forked from parcel-bundler/parcel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix to resovle dependencies with paths option in tsconfig parcel-bund…
- Loading branch information
Hyeonjae Park
committed
Feb 15, 2019
1 parent
a2e38f9
commit f6b12ff
Showing
12 changed files
with
131 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/core/parcel-bundler/test/integration/resolve-paths/app/foo.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
exports.getMessage = () => './app/foo.ts'; |
1 change: 1 addition & 0 deletions
1
packages/core/parcel-bundler/test/integration/resolve-paths/core/util/foo.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
exports.getMessage = () => './core/util/foo.ts'; |
7 changes: 7 additions & 0 deletions
7
packages/core/parcel-bundler/test/integration/resolve-paths/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import app_foo from '@app/foo'; | ||
import core_util_foo from '@core/foo'; | ||
import src_foo from '@src/foo'; | ||
|
||
app_foo.getMessage(); | ||
core_util_foo.getMessage(); | ||
src_foo.getMessage(); |
5 changes: 5 additions & 0 deletions
5
packages/core/parcel-bundler/test/integration/resolve-paths/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "resolve-paths", | ||
"version": "1.0.0", | ||
"main": "index.ts" | ||
} |
1 change: 1 addition & 0 deletions
1
packages/core/parcel-bundler/test/integration/resolve-paths/src/foo.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
exports.getMessage = () => './src/foo.js'; |
20 changes: 20 additions & 0 deletions
20
packages/core/parcel-bundler/test/integration/resolve-paths/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": ["esnext"], | ||
"allowJs": true, | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"noEmit": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"@app/*": ["./app/*"], | ||
"@core/*": ["./core/**"], | ||
"@src/*": ["./src"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const assert = require('assert'); | ||
const Path = require('path'); | ||
const Bundler = require('../src/Bundler'); | ||
|
||
describe('typescript asset', () => { | ||
it('should be resolved with tsconfig paths when bundled', async () => { | ||
const filename = Path.normalize( | ||
Path.join(__dirname, '/integration/resolve-paths/index.ts') | ||
); | ||
|
||
const options = { | ||
outDir: Path.join(__dirname, './integration/resolve-paths/dist'), | ||
outFile: 'index.js', | ||
cache: false, | ||
hmr: false | ||
}; | ||
|
||
const bundler = new Bundler(filename, options); | ||
const bundle = await bundler.bundle(); | ||
|
||
const loadedAssets = [...bundle.assets.values()].map(asset => asset.id); | ||
|
||
assert.equal(loadedAssets.includes('index.ts'), true); | ||
assert.equal(loadedAssets.includes('app/foo.ts'), true); | ||
assert.equal(loadedAssets.includes('core/util/foo.ts'), true); | ||
assert.equal(loadedAssets.includes('src/foo.ts'), true); | ||
}); | ||
}); |