Skip to content

Commit

Permalink
Refactor project layout
Browse files Browse the repository at this point in the history
- Leverage project references
- Replace hacks in the demo example
- Publish source maps
- Publish declaration maps
  • Loading branch information
remcohaszing committed Apr 16, 2024
1 parent 0843618 commit 87f7a92
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 46 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*.js
*.d.ts
*.tgz
*.tsbuildinfo
dist/
node_modules/
2 changes: 1 addition & 1 deletion examples/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"html-webpack-plugin": "^5.0.0",
"mini-css-extract-plugin": "^2.0.0",
"monaco-editor": "^0.41.0",
"monaco-unified": "file:..",
"monaco-unified": "file:../..",
"remark": "^15.0.0",
"remark-gfm": "^4.0.0",
"remark-lint-heading-increment": "^4.0.0",
Expand Down
10 changes: 10 additions & 0 deletions examples/demo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"references": [{ "path": "../../src/tsconfig.json" }],
"compilerOptions": {
"composite": true,
"module": "preserve",
"noEmit": true,
"strict": true,
"target": "esnext"
}
}
31 changes: 11 additions & 20 deletions examples/demo/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,39 @@
import { fileURLToPath } from 'url'

import CssMinimizerPlugin from 'css-minimizer-webpack-plugin'
import HtmlWebPackPlugin from 'html-webpack-plugin'
import MiniCssExtractPlugin from 'mini-css-extract-plugin'

const monacoUnified = new URL('../../', import.meta.url)
const nodeModules = new URL('node_modules/', monacoUnified)

/** @type {import('webpack').Configuration} */
export default {
output: {
filename: '[contenthash].js',
filename: '[contenthash].js'
},
resolve: {
extensions: ['.mjs', '.js', '.ts'],
extensionAlias: {
'.js': ['.js', '.ts'],
},
alias: {
'monaco-unified': fileURLToPath(monacoUnified),
'decode-named-character-reference': fileURLToPath(
new URL('decode-named-character-reference/index.js', nodeModules),
),
'.js': ['.js', '.ts']
},
conditionNames: ['worker']
},
module: {
rules: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
use: [MiniCssExtractPlugin.loader, 'css-loader']
},
{
// Monaco editor uses .ttf icons.
test: /\.(svg|ttf)$/,
type: 'asset/resource',
type: 'asset/resource'
},
{
test: /\.ts$/,
loader: 'ts-loader',
options: { transpileOnly: true },
},
],
options: { transpileOnly: true }
}
]
},
optimization: {
minimizer: ['...', new CssMinimizerPlugin()],
minimizer: ['...', new CssMinimizerPlugin()]
},
plugins: [new HtmlWebPackPlugin(), new MiniCssExtractPlugin({ filename: '[contenthash].css' })],
plugins: [new HtmlWebPackPlugin(), new MiniCssExtractPlugin({ filename: '[contenthash].css' })]
}
5 changes: 2 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
"examples/*"
],
"exports": {
".": "./index.js",
"./worker": "./worker.js"
".": "./dist/monaco-unified.js",
"./worker": "./dist/worker.js"
},
"files": [
"/*.js",
"/*.d.ts"
"dist",
"src",
"!tsconfig.json",
"!*.tsbuildinfo"
],
"keywords": [
"monaco",
Expand All @@ -32,7 +34,8 @@
"bugs": "https://github.com/remcohaszing/monaco-unified/issues",
"funding": "https://github.com/sponsors/remcohaszing",
"scripts": {
"prepack": "tsc --noEmit false",
"prepack": "tsc --build",
"prestart": "tsc --build",
"start": "npm --workspace demo start"
},
"dependencies": {
Expand Down
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"composite": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"module": "nodenext",
"noImplicitAny": true,
"outDir": "../dist",
"strict": true,
"stripInternal": true,
"types": []
}
}
File renamed without changes.
17 changes: 2 additions & 15 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
{
"compilerOptions": {
"declaration": true,
"module": "node16",
"noEmit": true,
"noImplicitAny": true,
"paths": {
"monaco-unified": ["./index.ts"],
"monaco-unified/worker": ["./worker.ts"]
},
"skipLibCheck": true,
"strict": true,
"stripInternal": true,
"target": "es2019",
"types": []
}
"files": [],
"references": [{ "path": "./src/tsconfig.json" }, {"path": "./examples/demo/tsconfig.json"}]
}

0 comments on commit 87f7a92

Please sign in to comment.