Skip to content

Commit

Permalink
chore(package): make it easier for monaco to resolve core dts file
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Jul 25, 2020
1 parent 62f018f commit 59ab8ee
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -2,8 +2,8 @@
"name": "@stencil/core",
"version": "1.17.0",
"license": "MIT",
"main": "internal/stencil-core.js",
"types": "internal/stencil-core.d.ts",
"main": "internal/stencil-core/index.js",
"types": "internal/stencil-core/index.d.ts",
"bin": {
"stencil": "bin/stencil"
},
Expand Down Expand Up @@ -140,4 +140,4 @@
"pwa",
"progressive web app"
]
}
}
12 changes: 8 additions & 4 deletions scripts/bundles/internal.ts
Expand Up @@ -72,10 +72,12 @@ async function copyStencilInternalDts(opts: BuildOptions, outputInternalDir: str
const runtimeDts = cleanDts(await fs.readFile(runtimeDtsSrcPath, 'utf8'));
await fs.writeFile(runtimeDtsDestPath, runtimeDts);

// @stencil/core/internal/stencil-core.d.ts file
// @stencil/core/internal/stencil-core/index.d.ts file
// actual public dts when importing @stencil/core
const stencilCoreDtsSrc = join(opts.buildDir, 'declarations', 'stencil-core.d.ts');
const stencilCoreDtsDst = join(outputInternalDir, 'stencil-core.d.ts');
const stencilCoreDtsSrc = join(opts.buildDir, 'declarations', 'stencil-core', 'index.d.ts');
const stencilCoreDstDir = join(outputInternalDir, 'stencil-core');
const stencilCoreDtsDst = join(stencilCoreDstDir, 'index.d.ts');
await fs.ensureDir(stencilCoreDstDir);
await fs.copyFile(stencilCoreDtsSrc, stencilCoreDtsDst);

// @stencil/core/internal/stencil-ext-modules.d.ts (.svg/.css)
Expand All @@ -90,5 +92,7 @@ function prependExtModules(content: string) {

async function createStencilCoreEntry(outputInternalDir: string) {
// write @stencil/core entry (really only used for node resolving, not its actual code as you can see)
await fs.writeFile(join(outputInternalDir, 'stencil-core.js'), `exports.h = function() {};`);
const stencilCoreDstDir = join(outputInternalDir, 'stencil-core');
await fs.ensureDir(stencilCoreDstDir);
await fs.writeFile(join(stencilCoreDstDir, 'index.js'), `exports.h = function() {};`);
}
4 changes: 2 additions & 2 deletions scripts/test/validate-build.ts
Expand Up @@ -58,8 +58,8 @@ const pkgs: TestPackage[] = [
// internal
packageJson: 'internal/package.json',
files: [
'internal/stencil-core.d.ts',
'internal/stencil-core.js',
'internal/stencil-core/index.js',
'internal/stencil-core/index.d.ts',
'internal/stencil-ext-modules.d.ts',
'internal/stencil-private.d.ts',
'internal/stencil-public-compiler.d.ts',
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/sys/dependencies.json
Expand Up @@ -8,8 +8,8 @@
"internal/index.js",
"internal/index.d.ts",
"internal/package.json",
"internal/stencil-core.js",
"internal/stencil-core.d.ts",
"internal/stencil-core/index.js",
"internal/stencil-core/index.d.ts",
"internal/stencil-ext-modules.d.ts",
"internal/stencil-private.d.ts",
"internal/stencil-public-compiler.d.ts",
Expand Down
Expand Up @@ -41,6 +41,6 @@ export {
VNodeData,
Watch,
writeTask,
} from './stencil-public-runtime';
} from '../stencil-public-runtime';

export { StencilConfig as Config, PrerenderConfig } from './stencil-public-compiler';
export { StencilConfig as Config, PrerenderConfig } from '../stencil-public-compiler';
1 change: 1 addition & 0 deletions tsconfig.json
Expand Up @@ -52,6 +52,7 @@
"src/compiler/index.ts",
"src/compiler/public.ts",
"src/compiler/sys/modules/index.ts",
"src/declarations/stencil-core/index.ts",
"src/dev-server/index.ts",
"src/dev-server/public.ts",
"src/dev-server/server-worker.ts",
Expand Down

0 comments on commit 59ab8ee

Please sign in to comment.