Visualize Your Ideas With Code
feat: add support for npm workspaces
aarthificial741567f8af41
diff --git a/.gitignore b/.gitignoreindex b4fb2306..cef6b09c 100644--- a/.gitignore+++ b/.gitignore@@ -1,5 +1,4 @@node_moduleslibtest-.idea-tsconfig.tsbuildinfo\ No newline at end of file+.idea\ No newline at end of filediff --git a/bin/index.mjs b/bin/index.mjsindex 9bb25025..147c4be1 100644--- a/bin/index.mjs+++ b/bin/index.mjs@@ -8,6 +8,7 @@ import WebpackDevServer from 'webpack-dev-server';import HtmlWebpackPlugin from 'html-webpack-plugin';import meow from 'meow';import UIPlugin from './plugins/UIPlugin.mjs';+import {createRequire} from 'module';const cli = meow({importMeta: import.meta,@@ -28,9 +29,16 @@ const cli = meow({},});-cli.flags.uiPath ||= cli.flags.uiServer- ? 'http://localhost:9001/main.js'- : './node_modules/@motion-canvas/ui/dist';+if (cli.flags.uiServer) {+ cli.flags.uiPath ||= 'http://localhost:9001/main.js';+} else {+ if (cli.flags.uiPath) {+ cli.flags.uiPath = path.resolve(process.cwd(), cli.flags.uiPath);+ } else {+ const require = createRequire(import.meta.url);+ cli.flags.uiPath = path.dirname(require.resolve('@motion-canvas/ui'));+ }+}const projectFile = path.resolve(process.cwd(), cli.input[0]);const renderOutput = path.resolve(process.cwd(), cli.flags.output);@@ -87,16 +95,11 @@ const compiler = webpack({},resolveLoader: {modules: [- path.resolve(process.cwd(), './node_modules'),- path.resolve(__dirname, '../node_modules'),+ 'node_modules',path.resolve(__dirname, './loaders'),],},resolve: {- modules: [- path.resolve(process.cwd(), './node_modules'),- path.resolve(__dirname, '../node_modules'),- ],extensions: ['.js', '.ts', '.tsx'],},output: {@@ -133,12 +136,11 @@ const server = new WebpackDevServer(});if (!cli.flags.uiServer) {- const ui = path.resolve(process.cwd(), cli.flags.uiPath);middlewares.unshift({name: 'ui',path: '/ui/:name',middleware: (req, res) => {- fs.createReadStream(path.join(ui, req.params.name), {+ fs.createReadStream(path.join(cli.flags.uiPath, req.params.name), {encoding: 'utf8',}).on('error', () => res.sendStatus(404))@@ -152,4 +154,4 @@ const server = new WebpackDevServer(},compiler,);-server.start().catch(console.error);+server.start().catch(console.error);\ No newline at end of filediff --git a/tsconfig.json b/tsconfig.jsonindex 78761f75..38c90d03 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -1,10 +1,8 @@{"compilerOptions": {- "rootDir": "src","baseUrl": "src","outDir": "lib",- "composite": true,- "sourceMap": true,+ "inlineSourceMap": true,"noImplicitAny": true,"module": "esnext","target": "es2020",diff --git a/tsconfig.local.json b/tsconfig.local.jsondeleted file mode 100644index 1803e1e3..00000000--- a/tsconfig.local.json+++ /dev/null@@ -1,26 +0,0 @@-{- "compilerOptions": {- "sourceMap": true,- "noImplicitAny": true,- "module": "esnext",- "target": "es2020",- "allowJs": true,- "moduleResolution": "node",- "resolveJsonModule": true,- "allowSyntheticDefaultImports": true,- "experimentalDecorators": true,- "jsx": "react-jsx",- "jsxImportSource": "@motion-canvas/core/lib",- "paths": {- "*": [- "../node_modules/*",- "../node_modules/@motion-canvas/core/node_modules/*",- "../node_modules/@motion-canvas/core/node_modules/@types/*"- ]- },- "typeRoots": [- "../node_modules/@motion-canvas/core/node_modules/@types",- "../node_modules/@types"- ]- }-}