Skip to content

Commit 9d93ec3

Browse files
authored
Fix TypeScript import issues (#286)
* TS fixes * Hide files in VSCode * gitignore embedded as well * Add embedded files to node package
1 parent 2233781 commit 9d93ec3

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ node_modules
77
/styles.css
88
/styles.scss
99
/styles
10-
/embedded.js
10+
/embedded.*
1111
/sandbox
1212
.DS_Store
1313
*.scss.d.ts

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"styles/": true,
1515
"types/": true,
1616
"index.*": true,
17-
"embedded.js": true,
17+
"embedded.*": true,
1818
"styles.{css,scss}": true
1919
},
2020
"search.exclude": {
@@ -25,7 +25,7 @@
2525
"styles/": true,
2626
"types/": true,
2727
"index.*": true,
28-
"embedded.js": true,
28+
"embedded.*": true,
2929
"styles.{css,scss}": true
3030
}
3131
}

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"postpublish": "in-publish && npm-run-all cdn show-private-readme || :"
4646
},
4747
"devDependencies": {
48-
"@shopify/images": "^1.0.0",
4948
"@shopify/js-uploader": "git+ssh://[email protected]/Shopify/js-uploader.git",
5049
"@types/enzyme": "^2.7.7",
5150
"@types/jest": "^19.2.2",
@@ -110,9 +109,12 @@
110109
"index.js",
111110
"index.es.js",
112111
"styles.css",
113-
"styles.scss"
112+
"styles.scss",
113+
"embedded.js",
114+
"embedded.d.ts"
114115
],
115116
"dependencies": {
117+
"@shopify/images": "^1.0.0",
116118
"@shopify/javascript-utilities": "^1.1.2",
117119
"@shopify/react-utilities": "^1.1.4",
118120
"@types/lodash": "^4.14.62",

scripts/build.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ execSync(`./node_modules/.bin/tsc --outDir ${intermediateBuild}`, {
1818
stdio: 'inherit',
1919
});
2020

21+
writeFileSync(resolvePath(root, 'embedded.d.ts'), "export * from './types/embedded';\n");
22+
2123
writeFileSync(resolvePath(intermediateBuild, '.babelrc'), `
2224
{
2325
"presets": [

tests/build.test.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,51 @@ const execSync = require('child_process').execSync;
22
const fs = require('fs-extra');
33

44
describe('build', () => {
5-
it('generates CDN files in ./build', () => {
5+
beforeEach(() => {
66
execSync('yarn run build');
7+
});
8+
9+
afterEach(() => {
10+
execSync('yarn run clean');
11+
});
12+
13+
it('generates CDN files in ./build', () => {
714
expect(fs.existsSync('./build/polaris.css')).toBe(true);
815
expect(fs.existsSync('./build/polaris.min.css')).toBe(true);
9-
execSync('yarn run clean');
1016
});
1117

1218
it('generates lib files in ./', () => {
13-
execSync('yarn run build');
1419
expect(fs.existsSync('./index.js')).toBe(true);
1520
expect(fs.existsSync('./embedded.js')).toBe(true);
1621
expect(fs.existsSync('./index.es.js')).toBe(true);
1722
expect(fs.existsSync('./styles.css')).toBe(true);
18-
execSync('yarn run clean');
1923
});
2024

2125
it('generates a ./styles/components dir with Icon.scss', () => {
22-
execSync('yarn run build');
2326
expect(fs.existsSync('./styles/components/Icon.scss')).toBe(true);
24-
execSync('yarn run clean');
2527
});
2628

2729
it('generates a ./styles/foundation dir with spacing.scss', () => {
28-
execSync('yarn run build');
2930
expect(fs.existsSync('./styles/foundation/spacing.scss')).toBe(true);
30-
execSync('yarn run clean');
3131
});
3232

3333
it('generates sass entries files in ./styles dir', () => {
34-
execSync('yarn run build');
3534
expect(fs.existsSync('./styles/global.scss')).toBe(true);
3635
expect(fs.existsSync('./styles/foundation.scss')).toBe(true);
3736
expect(fs.existsSync('./styles/shared.scss')).toBe(true);
3837
expect(fs.existsSync('./styles/components.scss')).toBe(true);
39-
execSync('yarn run clean');
4038
});
4139

4240
it('generates a ./styles.scss sass entry point in root', () => {
43-
execSync('yarn run build');
4441
expect(fs.existsSync('./styles.scss')).toBe(true);
45-
execSync('yarn run clean');
4642
});
4743

4844
it('generates a zip of ./build/sass', () => {
49-
execSync('yarn run build');
5045
expect(fs.existsSync('./build/sass.zip')).toBe(true);
51-
execSync('yarn run clean');
46+
});
47+
48+
it('generates the necessary typescript definition files', () => {
49+
expect(fs.existsSync('./types/index.d.ts')).toBe(true);
50+
expect(fs.existsSync('./embedded.d.ts')).toBe(true);
5251
});
5352
});

0 commit comments

Comments
 (0)